<?php


/**
 * Base class that represents a row from the 'car_damages' table.
 *
 *
 *
 * @package    propel.generator.damages.om
 */
abstract class DamagesBaseCarDamages extends BaseObject implements Persistent
{
    /**
     * Peer class name
     */
    const PEER = 'DamagesCarDamagesPeer';

    /**
     * The Peer class.
     * Instance provides a convenient way of calling static methods on a class
     * that calling code may not be able to identify.
     * @var        DamagesCarDamagesPeer
     */
    protected static $peer;

    /**
     * The flag var to prevent infinit loop in deep copy
     * @var       boolean
     */
    protected $startCopy = false;

    /**
     * The value for the id field.
     * @var        int
     */
    protected $id;

    /**
     * The value for the car_data_id field.
     * @var        int
     */
    protected $car_data_id;

    /**
     * The value for the status_id field.
     * @var        int
     */
    protected $status_id;

    /**
     * The value for the dict_perpetrator_id field.
     * @var        int
     */
    protected $dict_perpetrator_id;

    /**
     * The value for the process_type_id field.
     * @var        int
     */
    protected $process_type_id;

    /**
     * The value for the related_car_damage field.
     * @var        int
     */
    protected $related_car_damage;

    /**
     * The value for the ls_id field.
     * @var        int
     */
    protected $ls_id;

    /**
     * The value for the ol_id field.
     * @var        int
     */
    protected $ol_id;

    /**
     * The value for the discard_id field.
     * @var        int
     */
    protected $discard_id;

    /**
     * The value for the discard_description field.
     * @var        string
     */
    protected $discard_description;

    /**
     * The value for the damage_date field.
     * @var        string
     */
    protected $damage_date;

    /**
     * The value for the dealer_report_date field.
     * @var        string
     */
    protected $dealer_report_date;

    /**
     * The value for the perpetrator_report_date field.
     * @var        string
     */
    protected $perpetrator_report_date;

    /**
     * The value for the damages_description field.
     * @var        string
     */
    protected $damages_description;

    /**
     * The value for the description field.
     * @var        string
     */
    protected $description;

    /**
     * The value for the created field.
     * @var        string
     */
    protected $created;

    /**
     * The value for the modified field.
     * @var        string
     */
    protected $modified;

    /**
     * @var        CarDamages
     */
    protected $aCarDamagesRelatedByRelatedCarDamage;

    /**
     * @var        DictStatuses
     */
    protected $aDictStatuses;

    /**
     * @var        CarData
     */
    protected $aCarData;

    /**
     * @var        Users
     */
    protected $aUsersRelatedByLsId;

    /**
     * @var        Users
     */
    protected $aUsersRelatedByOlId;

    /**
     * @var        DictDiscards
     */
    protected $aDictDiscards;

    /**
     * @var        DictPerpetrators
     */
    protected $aDictPerpetrators;

    /**
     * @var        ProcessTypes
     */
    protected $aProcessTypes;

    /**
     * @var        PropelObjectCollection|DamagesAttachments[] Collection to store aggregation of DamagesAttachments objects.
     */
    protected $collAttachmentss;
    protected $collAttachmentssPartial;

    /**
     * @var        PropelObjectCollection|DamagesCarDamageChangeLogs[] Collection to store aggregation of DamagesCarDamageChangeLogs objects.
     */
    protected $collCarDamageChangeLogss;
    protected $collCarDamageChangeLogssPartial;

    /**
     * @var        PropelObjectCollection|DamagesCarDamages[] Collection to store aggregation of DamagesCarDamages objects.
     */
    protected $collCarDamagessRelatedById;
    protected $collCarDamagessRelatedByIdPartial;

    /**
     * @var        PropelObjectCollection|DamagesDamages[] Collection to store aggregation of DamagesDamages objects.
     */
    protected $collDamagess;
    protected $collDamagessPartial;

    /**
     * @var        PropelObjectCollection|DamagesEstimatedBudgets[] Collection to store aggregation of DamagesEstimatedBudgets objects.
     */
    protected $collEstimatedBudgetss;
    protected $collEstimatedBudgetssPartial;

    /**
     * @var        PropelObjectCollection|DamagesInvoices[] Collection to store aggregation of DamagesInvoices objects.
     */
    protected $collInvoicess;
    protected $collInvoicessPartial;

    /**
     * @var        PropelObjectCollection|DamagesNotes[] Collection to store aggregation of DamagesNotes objects.
     */
    protected $collNotess;
    protected $collNotessPartial;

    /**
     * Flag to prevent endless save loop, if this object is referenced
     * by another object which falls in this transaction.
     * @var        boolean
     */
    protected $alreadyInSave = false;

    /**
     * Flag to prevent endless validation loop, if this object is referenced
     * by another object which falls in this transaction.
     * @var        boolean
     */
    protected $alreadyInValidation = false;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $attachmentssScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $carDamageChangeLogssScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $carDamagessRelatedByIdScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $damagessScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $estimatedBudgetssScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $invoicessScheduledForDeletion = null;

    /**
     * An array of objects scheduled for deletion.
     * @var		PropelObjectCollection
     */
    protected $notessScheduledForDeletion = null;

    /**
     * Get the [id] column value.
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Get the [car_data_id] column value.
     *
     * @return int
     */
    public function getCarDataId()
    {
        return $this->car_data_id;
    }

    /**
     * Get the [status_id] column value.
     *
     * @return int
     */
    public function getStatusId()
    {
        return $this->status_id;
    }

    /**
     * Get the [dict_perpetrator_id] column value.
     *
     * @return int
     */
    public function getDictPerpetratorId()
    {
        return $this->dict_perpetrator_id;
    }

    /**
     * Get the [process_type_id] column value.
     *
     * @return int
     */
    public function getProcessTypeId()
    {
        return $this->process_type_id;
    }

    /**
     * Get the [related_car_damage] column value.
     *
     * @return int
     */
    public function getRelatedCarDamage()
    {
        return $this->related_car_damage;
    }

    /**
     * Get the [ls_id] column value.
     *
     * @return int
     */
    public function getLsId()
    {
        return $this->ls_id;
    }

    /**
     * Get the [ol_id] column value.
     *
     * @return int
     */
    public function getOlId()
    {
        return $this->ol_id;
    }

    /**
     * Get the [discard_id] column value.
     *
     * @return int
     */
    public function getDiscardId()
    {
        return $this->discard_id;
    }

    /**
     * Get the [discard_description] column value.
     *
     * @return string
     */
    public function getDiscardDescription()
    {
        return $this->discard_description;
    }

    /**
     * Get the [optionally formatted] temporal [damage_date] column value.
     *
     *
     * @param string $format The date/time format string (either date()-style or strftime()-style).
     *				 If format is null, then the raw DateTime object will be returned.
     * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getDamageDate($format = 'Y-m-d H:i:s')
    {
        if ($this->damage_date === null) {
            return null;
        }


        try {
            $dt = new DateTime($this->damage_date);
        } catch (Exception $x) {
            throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->damage_date, true), $x);
        }

        if ($format === null) {
            // Because propel.useDateTimeClass is true, we return a DateTime object.
            return $dt;
        } elseif (strpos($format, '%') !== false) {
            return strftime($format, $dt->format('U'));
        } else {
            return $dt->format($format);
        }
    }

    /**
     * Get the [optionally formatted] temporal [dealer_report_date] column value.
     *
     *
     * @param string $format The date/time format string (either date()-style or strftime()-style).
     *				 If format is null, then the raw DateTime object will be returned.
     * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getDealerReportDate($format = 'Y-m-d H:i:s')
    {
        if ($this->dealer_report_date === null) {
            return null;
        }


        try {
            $dt = new DateTime($this->dealer_report_date);
        } catch (Exception $x) {
            throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->dealer_report_date, true), $x);
        }

        if ($format === null) {
            // Because propel.useDateTimeClass is true, we return a DateTime object.
            return $dt;
        } elseif (strpos($format, '%') !== false) {
            return strftime($format, $dt->format('U'));
        } else {
            return $dt->format($format);
        }
    }

    /**
     * Get the [optionally formatted] temporal [perpetrator_report_date] column value.
     *
     *
     * @param string $format The date/time format string (either date()-style or strftime()-style).
     *				 If format is null, then the raw DateTime object will be returned.
     * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getPerpetratorReportDate($format = 'Y-m-d H:i:s')
    {
        if ($this->perpetrator_report_date === null) {
            return null;
        }


        try {
            $dt = new DateTime($this->perpetrator_report_date);
        } catch (Exception $x) {
            throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->perpetrator_report_date, true), $x);
        }

        if ($format === null) {
            // Because propel.useDateTimeClass is true, we return a DateTime object.
            return $dt;
        } elseif (strpos($format, '%') !== false) {
            return strftime($format, $dt->format('U'));
        } else {
            return $dt->format($format);
        }
    }

    /**
     * Get the [damages_description] column value.
     *
     * @return string
     */
    public function getDamagesDescription()
    {
        return $this->damages_description;
    }

    /**
     * Get the [description] column value.
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Get the [optionally formatted] temporal [created] column value.
     *
     *
     * @param string $format The date/time format string (either date()-style or strftime()-style).
     *				 If format is null, then the raw DateTime object will be returned.
     * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getCreated($format = 'Y-m-d H:i:s')
    {
        if ($this->created === null) {
            return null;
        }


        try {
            $dt = new DateTime($this->created);
        } catch (Exception $x) {
            throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, true), $x);
        }

        if ($format === null) {
            // Because propel.useDateTimeClass is true, we return a DateTime object.
            return $dt;
        } elseif (strpos($format, '%') !== false) {
            return strftime($format, $dt->format('U'));
        } else {
            return $dt->format($format);
        }
    }

    /**
     * Get the [optionally formatted] temporal [modified] column value.
     *
     *
     * @param string $format The date/time format string (either date()-style or strftime()-style).
     *				 If format is null, then the raw DateTime object will be returned.
     * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
     * @throws PropelException - if unable to parse/validate the date/time value.
     */
    public function getModified($format = 'Y-m-d H:i:s')
    {
        if ($this->modified === null) {
            return null;
        }


        try {
            $dt = new DateTime($this->modified);
        } catch (Exception $x) {
            throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->modified, true), $x);
        }

        if ($format === null) {
            // Because propel.useDateTimeClass is true, we return a DateTime object.
            return $dt;
        } elseif (strpos($format, '%') !== false) {
            return strftime($format, $dt->format('U'));
        } else {
            return $dt->format($format);
        }
    }

    /**
     * Set the value of [id] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->id !== $v) {
            $this->id = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::ID;
        }


        return $this;
    } // setId()

    /**
     * Set the value of [car_data_id] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setCarDataId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->car_data_id !== $v) {
            $this->car_data_id = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::CAR_DATA_ID;
        }

        if ($this->aCarData !== null && $this->aCarData->getId() !== $v) {
            $this->aCarData = null;
        }


        return $this;
    } // setCarDataId()

    /**
     * Set the value of [status_id] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setStatusId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->status_id !== $v) {
            $this->status_id = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::STATUS_ID;
        }

        if ($this->aDictStatuses !== null && $this->aDictStatuses->getId() !== $v) {
            $this->aDictStatuses = null;
        }


        return $this;
    } // setStatusId()

    /**
     * Set the value of [dict_perpetrator_id] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setDictPerpetratorId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->dict_perpetrator_id !== $v) {
            $this->dict_perpetrator_id = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::DICT_PERPETRATOR_ID;
        }

        if ($this->aDictPerpetrators !== null && $this->aDictPerpetrators->getId() !== $v) {
            $this->aDictPerpetrators = null;
        }


        return $this;
    } // setDictPerpetratorId()

    /**
     * Set the value of [process_type_id] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setProcessTypeId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->process_type_id !== $v) {
            $this->process_type_id = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::PROCESS_TYPE_ID;
        }

        if ($this->aProcessTypes !== null && $this->aProcessTypes->getId() !== $v) {
            $this->aProcessTypes = null;
        }


        return $this;
    } // setProcessTypeId()

    /**
     * Set the value of [related_car_damage] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setRelatedCarDamage($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->related_car_damage !== $v) {
            $this->related_car_damage = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::RELATED_CAR_DAMAGE;
        }

        if ($this->aCarDamagesRelatedByRelatedCarDamage !== null && $this->aCarDamagesRelatedByRelatedCarDamage->getId() !== $v) {
            $this->aCarDamagesRelatedByRelatedCarDamage = null;
        }


        return $this;
    } // setRelatedCarDamage()

    /**
     * Set the value of [ls_id] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setLsId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->ls_id !== $v) {
            $this->ls_id = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::LS_ID;
        }

        if ($this->aUsersRelatedByLsId !== null && $this->aUsersRelatedByLsId->getId() !== $v) {
            $this->aUsersRelatedByLsId = null;
        }


        return $this;
    } // setLsId()

    /**
     * Set the value of [ol_id] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setOlId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->ol_id !== $v) {
            $this->ol_id = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::OL_ID;
        }

        if ($this->aUsersRelatedByOlId !== null && $this->aUsersRelatedByOlId->getId() !== $v) {
            $this->aUsersRelatedByOlId = null;
        }


        return $this;
    } // setOlId()

    /**
     * Set the value of [discard_id] column.
     *
     * @param int $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setDiscardId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->discard_id !== $v) {
            $this->discard_id = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::DISCARD_ID;
        }

        if ($this->aDictDiscards !== null && $this->aDictDiscards->getId() !== $v) {
            $this->aDictDiscards = null;
        }


        return $this;
    } // setDiscardId()

    /**
     * Set the value of [discard_description] column.
     *
     * @param string $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setDiscardDescription($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->discard_description !== $v) {
            $this->discard_description = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::DISCARD_DESCRIPTION;
        }


        return $this;
    } // setDiscardDescription()

    /**
     * Sets the value of [damage_date] column to a normalized version of the date/time value specified.
     *
     * @param mixed $v string, integer (timestamp), or DateTime value.
     *               Empty strings are treated as null.
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setDamageDate($v)
    {
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
        if ($this->damage_date !== null || $dt !== null) {
            $currentDateAsString = ($this->damage_date !== null && $tmpDt = new DateTime($this->damage_date)) ? $tmpDt->format('Y-m-d H:i:s') : null;
            $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
            if ($currentDateAsString !== $newDateAsString) {
                $this->damage_date = $newDateAsString;
                $this->modifiedColumns[] = DamagesCarDamagesPeer::DAMAGE_DATE;
            }
        } // if either are not null


        return $this;
    } // setDamageDate()

    /**
     * Sets the value of [dealer_report_date] column to a normalized version of the date/time value specified.
     *
     * @param mixed $v string, integer (timestamp), or DateTime value.
     *               Empty strings are treated as null.
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setDealerReportDate($v)
    {
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
        if ($this->dealer_report_date !== null || $dt !== null) {
            $currentDateAsString = ($this->dealer_report_date !== null && $tmpDt = new DateTime($this->dealer_report_date)) ? $tmpDt->format('Y-m-d H:i:s') : null;
            $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
            if ($currentDateAsString !== $newDateAsString) {
                $this->dealer_report_date = $newDateAsString;
                $this->modifiedColumns[] = DamagesCarDamagesPeer::DEALER_REPORT_DATE;
            }
        } // if either are not null


        return $this;
    } // setDealerReportDate()

    /**
     * Sets the value of [perpetrator_report_date] column to a normalized version of the date/time value specified.
     *
     * @param mixed $v string, integer (timestamp), or DateTime value.
     *               Empty strings are treated as null.
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setPerpetratorReportDate($v)
    {
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
        if ($this->perpetrator_report_date !== null || $dt !== null) {
            $currentDateAsString = ($this->perpetrator_report_date !== null && $tmpDt = new DateTime($this->perpetrator_report_date)) ? $tmpDt->format('Y-m-d H:i:s') : null;
            $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
            if ($currentDateAsString !== $newDateAsString) {
                $this->perpetrator_report_date = $newDateAsString;
                $this->modifiedColumns[] = DamagesCarDamagesPeer::PERPETRATOR_REPORT_DATE;
            }
        } // if either are not null


        return $this;
    } // setPerpetratorReportDate()

    /**
     * Set the value of [damages_description] column.
     *
     * @param string $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setDamagesDescription($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->damages_description !== $v) {
            $this->damages_description = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::DAMAGES_DESCRIPTION;
        }


        return $this;
    } // setDamagesDescription()

    /**
     * Set the value of [description] column.
     *
     * @param string $v new value
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setDescription($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->description !== $v) {
            $this->description = $v;
            $this->modifiedColumns[] = DamagesCarDamagesPeer::DESCRIPTION;
        }


        return $this;
    } // setDescription()

    /**
     * Sets the value of [created] column to a normalized version of the date/time value specified.
     *
     * @param mixed $v string, integer (timestamp), or DateTime value.
     *               Empty strings are treated as null.
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setCreated($v)
    {
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
        if ($this->created !== null || $dt !== null) {
            $currentDateAsString = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $tmpDt->format('Y-m-d H:i:s') : null;
            $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
            if ($currentDateAsString !== $newDateAsString) {
                $this->created = $newDateAsString;
                $this->modifiedColumns[] = DamagesCarDamagesPeer::CREATED;
            }
        } // if either are not null


        return $this;
    } // setCreated()

    /**
     * Sets the value of [modified] column to a normalized version of the date/time value specified.
     *
     * @param mixed $v string, integer (timestamp), or DateTime value.
     *               Empty strings are treated as null.
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function setModified($v)
    {
        $dt = PropelDateTime::newInstance($v, null, 'DateTime');
        if ($this->modified !== null || $dt !== null) {
            $currentDateAsString = ($this->modified !== null && $tmpDt = new DateTime($this->modified)) ? $tmpDt->format('Y-m-d H:i:s') : null;
            $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
            if ($currentDateAsString !== $newDateAsString) {
                $this->modified = $newDateAsString;
                $this->modifiedColumns[] = DamagesCarDamagesPeer::MODIFIED;
            }
        } // if either are not null


        return $this;
    } // setModified()

    /**
     * Indicates whether the columns in this object are only set to default values.
     *
     * This method can be used in conjunction with isModified() to indicate whether an object is both
     * modified _and_ has some values set which are non-default.
     *
     * @return boolean Whether the columns in this object are only been set with default values.
     */
    public function hasOnlyDefaultValues()
    {
        // otherwise, everything was equal, so return true
        return true;
    } // hasOnlyDefaultValues()

    /**
     * Hydrates (populates) the object variables with values from the database resultset.
     *
     * An offset (0-based "start column") is specified so that objects can be hydrated
     * with a subset of the columns in the resultset rows.  This is needed, for example,
     * for results of JOIN queries where the resultset row includes columns from two or
     * more tables.
     *
     * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
     * @param int $startcol 0-based offset column which indicates which restultset column to start with.
     * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
     * @return int             next starting column
     * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
     */
    public function hydrate($row, $startcol = 0, $rehydrate = false)
    {
        try {

            $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
            $this->car_data_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
            $this->status_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
            $this->dict_perpetrator_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
            $this->process_type_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
            $this->related_car_damage = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
            $this->ls_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
            $this->ol_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
            $this->discard_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
            $this->discard_description = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
            $this->damage_date = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null;
            $this->dealer_report_date = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
            $this->perpetrator_report_date = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
            $this->damages_description = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
            $this->description = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null;
            $this->created = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
            $this->modified = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
            $this->resetModified();

            $this->setNew(false);

            if ($rehydrate) {
                $this->ensureConsistency();
            }

            return $startcol + 17; // 17 = DamagesCarDamagesPeer::NUM_HYDRATE_COLUMNS.

        } catch (Exception $e) {
            throw new PropelException("Error populating DamagesCarDamages object", $e);
        }
    }

    /**
     * Checks and repairs the internal consistency of the object.
     *
     * This method is executed after an already-instantiated object is re-hydrated
     * from the database.  It exists to check any foreign keys to make sure that
     * the objects related to the current object are correct based on foreign key.
     *
     * You can override this method in the stub class, but you should always invoke
     * the base method from the overridden method (i.e. parent::ensureConsistency()),
     * in case your model changes.
     *
     * @throws PropelException
     */
    public function ensureConsistency()
    {

        if ($this->aCarData !== null && $this->car_data_id !== $this->aCarData->getId()) {
            $this->aCarData = null;
        }
        if ($this->aDictStatuses !== null && $this->status_id !== $this->aDictStatuses->getId()) {
            $this->aDictStatuses = null;
        }
        if ($this->aDictPerpetrators !== null && $this->dict_perpetrator_id !== $this->aDictPerpetrators->getId()) {
            $this->aDictPerpetrators = null;
        }
        if ($this->aProcessTypes !== null && $this->process_type_id !== $this->aProcessTypes->getId()) {
            $this->aProcessTypes = null;
        }
        if ($this->aCarDamagesRelatedByRelatedCarDamage !== null && $this->related_car_damage !== $this->aCarDamagesRelatedByRelatedCarDamage->getId()) {
            $this->aCarDamagesRelatedByRelatedCarDamage = null;
        }
        if ($this->aUsersRelatedByLsId !== null && $this->ls_id !== $this->aUsersRelatedByLsId->getId()) {
            $this->aUsersRelatedByLsId = null;
        }
        if ($this->aUsersRelatedByOlId !== null && $this->ol_id !== $this->aUsersRelatedByOlId->getId()) {
            $this->aUsersRelatedByOlId = null;
        }
        if ($this->aDictDiscards !== null && $this->discard_id !== $this->aDictDiscards->getId()) {
            $this->aDictDiscards = null;
        }
    } // ensureConsistency

    /**
     * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
     *
     * This will only work if the object has been saved and has a valid primary key set.
     *
     * @param boolean $deep (optional) Whether to also de-associated any related objects.
     * @param PropelPDO $con (optional) The PropelPDO connection to use.
     * @return void
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
     */
    public function reload($deep = false, PropelPDO $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("Cannot reload a deleted object.");
        }

        if ($this->isNew()) {
            throw new PropelException("Cannot reload an unsaved object.");
        }

        if ($con === null) {
            $con = Propel::getConnection(DamagesCarDamagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }

        // We don't need to alter the object instance pool; we're just modifying this instance
        // already in the pool.

        $stmt = DamagesCarDamagesPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
        $row = $stmt->fetch(PDO::FETCH_NUM);
        $stmt->closeCursor();
        if (!$row) {
            throw new PropelException('Cannot find matching row in the database to reload object values.');
        }
        $this->hydrate($row, 0, true); // rehydrate

        if ($deep) {  // also de-associate any related objects?

            $this->aCarDamagesRelatedByRelatedCarDamage = null;
            $this->aDictStatuses = null;
            $this->aCarData = null;
            $this->aUsersRelatedByLsId = null;
            $this->aUsersRelatedByOlId = null;
            $this->aDictDiscards = null;
            $this->aDictPerpetrators = null;
            $this->aProcessTypes = null;
            $this->collAttachmentss = null;

            $this->collCarDamageChangeLogss = null;

            $this->collCarDamagessRelatedById = null;

            $this->collDamagess = null;

            $this->collEstimatedBudgetss = null;

            $this->collInvoicess = null;

            $this->collNotess = null;

        } // if (deep)
    }

    /**
     * Removes this object from datastore and sets delete attribute.
     *
     * @param PropelPDO $con
     * @return void
     * @throws PropelException
     * @throws Exception
     * @see        BaseObject::setDeleted()
     * @see        BaseObject::isDeleted()
     */
    public function delete(PropelPDO $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("This object has already been deleted.");
        }

        if ($con === null) {
            $con = Propel::getConnection(DamagesCarDamagesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
        }

        $con->beginTransaction();
        try {
            $deleteQuery = DamagesCarDamagesQuery::create()
                ->filterByPrimaryKey($this->getPrimaryKey());
            $ret = $this->preDelete($con);
            if ($ret) {
                $deleteQuery->delete($con);
                $this->postDelete($con);
                $con->commit();
                $this->setDeleted(true);
            } else {
                $con->commit();
            }
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }
    }

    /**
     * Persists this object to the database.
     *
     * If the object is new, it inserts it; otherwise an update is performed.
     * All modified related objects will also be persisted in the doSave()
     * method.  This method wraps all precipitate database operations in a
     * single transaction.
     *
     * @param PropelPDO $con
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     * @throws PropelException
     * @throws Exception
     * @see        doSave()
     */
    public function save(PropelPDO $con = null)
    {
        if ($this->isDeleted()) {
            throw new PropelException("You cannot save an object that has been deleted.");
        }

        if ($con === null) {
            $con = Propel::getConnection(DamagesCarDamagesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
        }

        $con->beginTransaction();
        $isInsert = $this->isNew();
        try {
            $ret = $this->preSave($con);
            if ($isInsert) {
                $ret = $ret && $this->preInsert($con);
            } else {
                $ret = $ret && $this->preUpdate($con);
            }
            if ($ret) {
                $affectedRows = $this->doSave($con);
                if ($isInsert) {
                    $this->postInsert($con);
                } else {
                    $this->postUpdate($con);
                }
                $this->postSave($con);
                DamagesCarDamagesPeer::addInstanceToPool($this);
            } else {
                $affectedRows = 0;
            }
            $con->commit();

            return $affectedRows;
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }
    }

    /**
     * Performs the work of inserting or updating the row in the database.
     *
     * If the object is new, it inserts it; otherwise an update is performed.
     * All related objects are also updated in this method.
     *
     * @param PropelPDO $con
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     * @throws PropelException
     * @see        save()
     */
    protected function doSave(PropelPDO $con)
    {
        $affectedRows = 0; // initialize var to track total num of affected rows
        if (!$this->alreadyInSave) {
            $this->alreadyInSave = true;

            // We call the save method on the following object(s) if they
            // were passed to this object by their coresponding set
            // method.  This object relates to these object(s) by a
            // foreign key reference.

            if ($this->aCarDamagesRelatedByRelatedCarDamage !== null) {
                if ($this->aCarDamagesRelatedByRelatedCarDamage->isModified() || $this->aCarDamagesRelatedByRelatedCarDamage->isNew()) {
                    $affectedRows += $this->aCarDamagesRelatedByRelatedCarDamage->save($con);
                }
                $this->setCarDamagesRelatedByRelatedCarDamage($this->aCarDamagesRelatedByRelatedCarDamage);
            }

            if ($this->aDictStatuses !== null) {
                if ($this->aDictStatuses->isModified() || $this->aDictStatuses->isNew()) {
                    $affectedRows += $this->aDictStatuses->save($con);
                }
                $this->setDictStatuses($this->aDictStatuses);
            }

            if ($this->aCarData !== null) {
                if ($this->aCarData->isModified() || $this->aCarData->isNew()) {
                    $affectedRows += $this->aCarData->save($con);
                }
                $this->setCarData($this->aCarData);
            }

            if ($this->aUsersRelatedByLsId !== null) {
                if ($this->aUsersRelatedByLsId->isModified() || $this->aUsersRelatedByLsId->isNew()) {
                    $affectedRows += $this->aUsersRelatedByLsId->save($con);
                }
                $this->setUsersRelatedByLsId($this->aUsersRelatedByLsId);
            }

            if ($this->aUsersRelatedByOlId !== null) {
                if ($this->aUsersRelatedByOlId->isModified() || $this->aUsersRelatedByOlId->isNew()) {
                    $affectedRows += $this->aUsersRelatedByOlId->save($con);
                }
                $this->setUsersRelatedByOlId($this->aUsersRelatedByOlId);
            }

            if ($this->aDictDiscards !== null) {
                if ($this->aDictDiscards->isModified() || $this->aDictDiscards->isNew()) {
                    $affectedRows += $this->aDictDiscards->save($con);
                }
                $this->setDictDiscards($this->aDictDiscards);
            }

            if ($this->aDictPerpetrators !== null) {
                if ($this->aDictPerpetrators->isModified() || $this->aDictPerpetrators->isNew()) {
                    $affectedRows += $this->aDictPerpetrators->save($con);
                }
                $this->setDictPerpetrators($this->aDictPerpetrators);
            }

            if ($this->aProcessTypes !== null) {
                if ($this->aProcessTypes->isModified() || $this->aProcessTypes->isNew()) {
                    $affectedRows += $this->aProcessTypes->save($con);
                }
                $this->setProcessTypes($this->aProcessTypes);
            }

            if ($this->isNew() || $this->isModified()) {
                // persist changes
                if ($this->isNew()) {
                    $this->doInsert($con);
                } else {
                    $this->doUpdate($con);
                }
                $affectedRows += 1;
                $this->resetModified();
            }

            if ($this->attachmentssScheduledForDeletion !== null) {
                if (!$this->attachmentssScheduledForDeletion->isEmpty()) {
                    foreach ($this->attachmentssScheduledForDeletion as $attachments) {
                        // need to save related object because we set the relation to null
                        $attachments->save($con);
                    }
                    $this->attachmentssScheduledForDeletion = null;
                }
            }

            if ($this->collAttachmentss !== null) {
                foreach ($this->collAttachmentss as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->carDamageChangeLogssScheduledForDeletion !== null) {
                if (!$this->carDamageChangeLogssScheduledForDeletion->isEmpty()) {
                    DamagesCarDamageChangeLogsQuery::create()
                        ->filterByPrimaryKeys($this->carDamageChangeLogssScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->carDamageChangeLogssScheduledForDeletion = null;
                }
            }

            if ($this->collCarDamageChangeLogss !== null) {
                foreach ($this->collCarDamageChangeLogss as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->carDamagessRelatedByIdScheduledForDeletion !== null) {
                if (!$this->carDamagessRelatedByIdScheduledForDeletion->isEmpty()) {
                    foreach ($this->carDamagessRelatedByIdScheduledForDeletion as $carDamagesRelatedById) {
                        // need to save related object because we set the relation to null
                        $carDamagesRelatedById->save($con);
                    }
                    $this->carDamagessRelatedByIdScheduledForDeletion = null;
                }
            }

            if ($this->collCarDamagessRelatedById !== null) {
                foreach ($this->collCarDamagessRelatedById as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->damagessScheduledForDeletion !== null) {
                if (!$this->damagessScheduledForDeletion->isEmpty()) {
                    DamagesDamagesQuery::create()
                        ->filterByPrimaryKeys($this->damagessScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->damagessScheduledForDeletion = null;
                }
            }

            if ($this->collDamagess !== null) {
                foreach ($this->collDamagess as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->estimatedBudgetssScheduledForDeletion !== null) {
                if (!$this->estimatedBudgetssScheduledForDeletion->isEmpty()) {
                    DamagesEstimatedBudgetsQuery::create()
                        ->filterByPrimaryKeys($this->estimatedBudgetssScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->estimatedBudgetssScheduledForDeletion = null;
                }
            }

            if ($this->collEstimatedBudgetss !== null) {
                foreach ($this->collEstimatedBudgetss as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->invoicessScheduledForDeletion !== null) {
                if (!$this->invoicessScheduledForDeletion->isEmpty()) {
                    DamagesInvoicesQuery::create()
                        ->filterByPrimaryKeys($this->invoicessScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->invoicessScheduledForDeletion = null;
                }
            }

            if ($this->collInvoicess !== null) {
                foreach ($this->collInvoicess as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            if ($this->notessScheduledForDeletion !== null) {
                if (!$this->notessScheduledForDeletion->isEmpty()) {
                    DamagesNotesQuery::create()
                        ->filterByPrimaryKeys($this->notessScheduledForDeletion->getPrimaryKeys(false))
                        ->delete($con);
                    $this->notessScheduledForDeletion = null;
                }
            }

            if ($this->collNotess !== null) {
                foreach ($this->collNotess as $referrerFK) {
                    if (!$referrerFK->isDeleted()) {
                        $affectedRows += $referrerFK->save($con);
                    }
                }
            }

            $this->alreadyInSave = false;

        }

        return $affectedRows;
    } // doSave()

    /**
     * Insert the row in the database.
     *
     * @param PropelPDO $con
     *
     * @throws PropelException
     * @see        doSave()
     */
    protected function doInsert(PropelPDO $con)
    {
        $this->modifiedColumns[] = DamagesCarDamagesPeer::ID;
        $criteria = $this->buildCriteria();
        if ($criteria->keyContainsValue(DamagesCarDamagesPeer::ID) ) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . DamagesCarDamagesPeer::ID . ')');
        }
        // remove pkey col since this table uses auto-increment and passing a null value for it is not valid
        $criteria->remove(DamagesCarDamagesPeer::ID);
        $pk = BasePeer::doInsert($criteria, $con);
        $this->setId($pk);  //[IMV] update autoincrement primary key
        $this->setNew(false);
    }

    /**
     * Update the row in the database.
     *
     * @param PropelPDO $con
     *
     * @see        doSave()
     */
    protected function doUpdate(PropelPDO $con)
    {
        $selectCriteria = $this->buildPkeyCriteria();
        $valuesCriteria = $this->buildCriteria();
        BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
    }

    /**
     * Array of ValidationFailed objects.
     * @var        array ValidationFailed[]
     */
    protected $validationFailures = array();

    /**
     * Gets any ValidationFailed objects that resulted from last call to validate().
     *
     *
     * @return array ValidationFailed[]
     * @see        validate()
     */
    public function getValidationFailures()
    {
        return $this->validationFailures;
    }

    /**
     * Validates the objects modified field values and all objects related to this table.
     *
     * If $columns is either a column name or an array of column names
     * only those columns are validated.
     *
     * @param mixed $columns Column name or an array of column names.
     * @return boolean Whether all columns pass validation.
     * @see        doValidate()
     * @see        getValidationFailures()
     */
    public function validate($columns = null)
    {
        $res = $this->doValidate($columns);
        if ($res === true) {
            $this->validationFailures = array();

            return true;
        } else {
            $this->validationFailures = $res;

            return false;
        }
    }

    /**
     * This function performs the validation work for complex object models.
     *
     * In addition to checking the current object, all related objects will
     * also be validated.  If all pass then <code>true</code> is returned; otherwise
     * an aggreagated array of ValidationFailed objects will be returned.
     *
     * @param array $columns Array of column names to validate.
     * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
     */
    protected function doValidate($columns = null)
    {
        if (!$this->alreadyInValidation) {
            $this->alreadyInValidation = true;
            $retval = null;

            $failureMap = array();


            // We call the validate method on the following object(s) if they
            // were passed to this object by their coresponding set
            // method.  This object relates to these object(s) by a
            // foreign key reference.

            if ($this->aCarDamagesRelatedByRelatedCarDamage !== null) {
                if (!$this->aCarDamagesRelatedByRelatedCarDamage->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aCarDamagesRelatedByRelatedCarDamage->getValidationFailures());
                }
            }

            if ($this->aDictStatuses !== null) {
                if (!$this->aDictStatuses->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aDictStatuses->getValidationFailures());
                }
            }

            if ($this->aCarData !== null) {
                if (!$this->aCarData->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aCarData->getValidationFailures());
                }
            }

            if ($this->aUsersRelatedByLsId !== null) {
                if (!$this->aUsersRelatedByLsId->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aUsersRelatedByLsId->getValidationFailures());
                }
            }

            if ($this->aUsersRelatedByOlId !== null) {
                if (!$this->aUsersRelatedByOlId->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aUsersRelatedByOlId->getValidationFailures());
                }
            }

            if ($this->aDictDiscards !== null) {
                if (!$this->aDictDiscards->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aDictDiscards->getValidationFailures());
                }
            }

            if ($this->aDictPerpetrators !== null) {
                if (!$this->aDictPerpetrators->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aDictPerpetrators->getValidationFailures());
                }
            }

            if ($this->aProcessTypes !== null) {
                if (!$this->aProcessTypes->validate($columns)) {
                    $failureMap = array_merge($failureMap, $this->aProcessTypes->getValidationFailures());
                }
            }


            if (($retval = DamagesCarDamagesPeer::doValidate($this, $columns)) !== true) {
                $failureMap = array_merge($failureMap, $retval);
            }


                if ($this->collAttachmentss !== null) {
                    foreach ($this->collAttachmentss as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collCarDamageChangeLogss !== null) {
                    foreach ($this->collCarDamageChangeLogss as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collCarDamagessRelatedById !== null) {
                    foreach ($this->collCarDamagessRelatedById as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collDamagess !== null) {
                    foreach ($this->collDamagess as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collEstimatedBudgetss !== null) {
                    foreach ($this->collEstimatedBudgetss as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collInvoicess !== null) {
                    foreach ($this->collInvoicess as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }

                if ($this->collNotess !== null) {
                    foreach ($this->collNotess as $referrerFK) {
                        if (!$referrerFK->validate($columns)) {
                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                        }
                    }
                }


            $this->alreadyInValidation = false;
        }

        return (!empty($failureMap) ? $failureMap : true);
    }

    /**
     * Retrieves a field from the object by name passed in as a string.
     *
     * @param string $name name
     * @param string $type The type of fieldname the $name is of:
     *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     *               Defaults to BasePeer::TYPE_PHPNAME
     * @return mixed Value of field.
     */
    public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
    {
        $pos = DamagesCarDamagesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
        $field = $this->getByPosition($pos);

        return $field;
    }

    /**
     * Retrieves a field from the object by Position as specified in the xml schema.
     * Zero-based.
     *
     * @param int $pos position in xml schema
     * @return mixed Value of field at $pos
     */
    public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getCarDataId();
                break;
            case 2:
                return $this->getStatusId();
                break;
            case 3:
                return $this->getDictPerpetratorId();
                break;
            case 4:
                return $this->getProcessTypeId();
                break;
            case 5:
                return $this->getRelatedCarDamage();
                break;
            case 6:
                return $this->getLsId();
                break;
            case 7:
                return $this->getOlId();
                break;
            case 8:
                return $this->getDiscardId();
                break;
            case 9:
                return $this->getDiscardDescription();
                break;
            case 10:
                return $this->getDamageDate();
                break;
            case 11:
                return $this->getDealerReportDate();
                break;
            case 12:
                return $this->getPerpetratorReportDate();
                break;
            case 13:
                return $this->getDamagesDescription();
                break;
            case 14:
                return $this->getDescription();
                break;
            case 15:
                return $this->getCreated();
                break;
            case 16:
                return $this->getModified();
                break;
            default:
                return null;
                break;
        } // switch()
    }

    /**
     * Exports the object as an array.
     *
     * You can specify the key type of the array by passing one of the class
     * type constants.
     *
     * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     *                    Defaults to BasePeer::TYPE_PHPNAME.
     * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
     * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
     * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
     *
     * @return array an associative array containing the field names (as keys) and field values
     */
    public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
    {
        if (isset($alreadyDumpedObjects['DamagesCarDamages'][$this->getPrimaryKey()])) {
            return '*RECURSION*';
        }
        $alreadyDumpedObjects['DamagesCarDamages'][$this->getPrimaryKey()] = true;
        $keys = DamagesCarDamagesPeer::getFieldNames($keyType);
        $result = array(
            $keys[0] => $this->getId(),
            $keys[1] => $this->getCarDataId(),
            $keys[2] => $this->getStatusId(),
            $keys[3] => $this->getDictPerpetratorId(),
            $keys[4] => $this->getProcessTypeId(),
            $keys[5] => $this->getRelatedCarDamage(),
            $keys[6] => $this->getLsId(),
            $keys[7] => $this->getOlId(),
            $keys[8] => $this->getDiscardId(),
            $keys[9] => $this->getDiscardDescription(),
            $keys[10] => $this->getDamageDate(),
            $keys[11] => $this->getDealerReportDate(),
            $keys[12] => $this->getPerpetratorReportDate(),
            $keys[13] => $this->getDamagesDescription(),
            $keys[14] => $this->getDescription(),
            $keys[15] => $this->getCreated(),
            $keys[16] => $this->getModified(),
        );
        if ($includeForeignObjects) {
            if (null !== $this->aCarDamagesRelatedByRelatedCarDamage) {
                $result['CarDamagesRelatedByRelatedCarDamage'] = $this->aCarDamagesRelatedByRelatedCarDamage->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->aDictStatuses) {
                $result['DictStatuses'] = $this->aDictStatuses->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->aCarData) {
                $result['CarData'] = $this->aCarData->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->aUsersRelatedByLsId) {
                $result['UsersRelatedByLsId'] = $this->aUsersRelatedByLsId->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->aUsersRelatedByOlId) {
                $result['UsersRelatedByOlId'] = $this->aUsersRelatedByOlId->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->aDictDiscards) {
                $result['DictDiscards'] = $this->aDictDiscards->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->aDictPerpetrators) {
                $result['DictPerpetrators'] = $this->aDictPerpetrators->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->aProcessTypes) {
                $result['ProcessTypes'] = $this->aProcessTypes->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
            }
            if (null !== $this->collAttachmentss) {
                $result['Attachmentss'] = $this->collAttachmentss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collCarDamageChangeLogss) {
                $result['CarDamageChangeLogss'] = $this->collCarDamageChangeLogss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collCarDamagessRelatedById) {
                $result['CarDamagessRelatedById'] = $this->collCarDamagessRelatedById->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collDamagess) {
                $result['Damagess'] = $this->collDamagess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collEstimatedBudgetss) {
                $result['EstimatedBudgetss'] = $this->collEstimatedBudgetss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collInvoicess) {
                $result['Invoicess'] = $this->collInvoicess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
            if (null !== $this->collNotess) {
                $result['Notess'] = $this->collNotess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
            }
        }

        return $result;
    }

    /**
     * Sets a field from the object by name passed in as a string.
     *
     * @param string $name peer name
     * @param mixed $value field value
     * @param string $type The type of fieldname the $name is of:
     *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     *                     Defaults to BasePeer::TYPE_PHPNAME
     * @return void
     */
    public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
    {
        $pos = DamagesCarDamagesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);

        $this->setByPosition($pos, $value);
    }

    /**
     * Sets a field from the object by Position as specified in the xml schema.
     * Zero-based.
     *
     * @param int $pos position in xml schema
     * @param mixed $value field value
     * @return void
     */
    public function setByPosition($pos, $value)
    {
        switch ($pos) {
            case 0:
                $this->setId($value);
                break;
            case 1:
                $this->setCarDataId($value);
                break;
            case 2:
                $this->setStatusId($value);
                break;
            case 3:
                $this->setDictPerpetratorId($value);
                break;
            case 4:
                $this->setProcessTypeId($value);
                break;
            case 5:
                $this->setRelatedCarDamage($value);
                break;
            case 6:
                $this->setLsId($value);
                break;
            case 7:
                $this->setOlId($value);
                break;
            case 8:
                $this->setDiscardId($value);
                break;
            case 9:
                $this->setDiscardDescription($value);
                break;
            case 10:
                $this->setDamageDate($value);
                break;
            case 11:
                $this->setDealerReportDate($value);
                break;
            case 12:
                $this->setPerpetratorReportDate($value);
                break;
            case 13:
                $this->setDamagesDescription($value);
                break;
            case 14:
                $this->setDescription($value);
                break;
            case 15:
                $this->setCreated($value);
                break;
            case 16:
                $this->setModified($value);
                break;
        } // switch()
    }

    /**
     * Populates the object using an array.
     *
     * This is particularly useful when populating an object from one of the
     * request arrays (e.g. $_POST).  This method goes through the column
     * names, checking to see whether a matching key exists in populated
     * array. If so the setByName() method is called for that column.
     *
     * You can specify the key type of the array by additionally passing one
     * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     * The default key type is the column's BasePeer::TYPE_PHPNAME
     *
     * @param array  $arr     An array to populate the object from.
     * @param string $keyType The type of keys the array uses.
     * @return void
     */
    public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
    {
        $keys = DamagesCarDamagesPeer::getFieldNames($keyType);

        if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
        if (array_key_exists($keys[1], $arr)) $this->setCarDataId($arr[$keys[1]]);
        if (array_key_exists($keys[2], $arr)) $this->setStatusId($arr[$keys[2]]);
        if (array_key_exists($keys[3], $arr)) $this->setDictPerpetratorId($arr[$keys[3]]);
        if (array_key_exists($keys[4], $arr)) $this->setProcessTypeId($arr[$keys[4]]);
        if (array_key_exists($keys[5], $arr)) $this->setRelatedCarDamage($arr[$keys[5]]);
        if (array_key_exists($keys[6], $arr)) $this->setLsId($arr[$keys[6]]);
        if (array_key_exists($keys[7], $arr)) $this->setOlId($arr[$keys[7]]);
        if (array_key_exists($keys[8], $arr)) $this->setDiscardId($arr[$keys[8]]);
        if (array_key_exists($keys[9], $arr)) $this->setDiscardDescription($arr[$keys[9]]);
        if (array_key_exists($keys[10], $arr)) $this->setDamageDate($arr[$keys[10]]);
        if (array_key_exists($keys[11], $arr)) $this->setDealerReportDate($arr[$keys[11]]);
        if (array_key_exists($keys[12], $arr)) $this->setPerpetratorReportDate($arr[$keys[12]]);
        if (array_key_exists($keys[13], $arr)) $this->setDamagesDescription($arr[$keys[13]]);
        if (array_key_exists($keys[14], $arr)) $this->setDescription($arr[$keys[14]]);
        if (array_key_exists($keys[15], $arr)) $this->setCreated($arr[$keys[15]]);
        if (array_key_exists($keys[16], $arr)) $this->setModified($arr[$keys[16]]);
    }

    /**
     * Build a Criteria object containing the values of all modified columns in this object.
     *
     * @return Criteria The Criteria object containing all modified values.
     */
    public function buildCriteria()
    {
        $criteria = new Criteria(DamagesCarDamagesPeer::DATABASE_NAME);

        if ($this->isColumnModified(DamagesCarDamagesPeer::ID)) $criteria->add(DamagesCarDamagesPeer::ID, $this->id);
        if ($this->isColumnModified(DamagesCarDamagesPeer::CAR_DATA_ID)) $criteria->add(DamagesCarDamagesPeer::CAR_DATA_ID, $this->car_data_id);
        if ($this->isColumnModified(DamagesCarDamagesPeer::STATUS_ID)) $criteria->add(DamagesCarDamagesPeer::STATUS_ID, $this->status_id);
        if ($this->isColumnModified(DamagesCarDamagesPeer::DICT_PERPETRATOR_ID)) $criteria->add(DamagesCarDamagesPeer::DICT_PERPETRATOR_ID, $this->dict_perpetrator_id);
        if ($this->isColumnModified(DamagesCarDamagesPeer::PROCESS_TYPE_ID)) $criteria->add(DamagesCarDamagesPeer::PROCESS_TYPE_ID, $this->process_type_id);
        if ($this->isColumnModified(DamagesCarDamagesPeer::RELATED_CAR_DAMAGE)) $criteria->add(DamagesCarDamagesPeer::RELATED_CAR_DAMAGE, $this->related_car_damage);
        if ($this->isColumnModified(DamagesCarDamagesPeer::LS_ID)) $criteria->add(DamagesCarDamagesPeer::LS_ID, $this->ls_id);
        if ($this->isColumnModified(DamagesCarDamagesPeer::OL_ID)) $criteria->add(DamagesCarDamagesPeer::OL_ID, $this->ol_id);
        if ($this->isColumnModified(DamagesCarDamagesPeer::DISCARD_ID)) $criteria->add(DamagesCarDamagesPeer::DISCARD_ID, $this->discard_id);
        if ($this->isColumnModified(DamagesCarDamagesPeer::DISCARD_DESCRIPTION)) $criteria->add(DamagesCarDamagesPeer::DISCARD_DESCRIPTION, $this->discard_description);
        if ($this->isColumnModified(DamagesCarDamagesPeer::DAMAGE_DATE)) $criteria->add(DamagesCarDamagesPeer::DAMAGE_DATE, $this->damage_date);
        if ($this->isColumnModified(DamagesCarDamagesPeer::DEALER_REPORT_DATE)) $criteria->add(DamagesCarDamagesPeer::DEALER_REPORT_DATE, $this->dealer_report_date);
        if ($this->isColumnModified(DamagesCarDamagesPeer::PERPETRATOR_REPORT_DATE)) $criteria->add(DamagesCarDamagesPeer::PERPETRATOR_REPORT_DATE, $this->perpetrator_report_date);
        if ($this->isColumnModified(DamagesCarDamagesPeer::DAMAGES_DESCRIPTION)) $criteria->add(DamagesCarDamagesPeer::DAMAGES_DESCRIPTION, $this->damages_description);
        if ($this->isColumnModified(DamagesCarDamagesPeer::DESCRIPTION)) $criteria->add(DamagesCarDamagesPeer::DESCRIPTION, $this->description);
        if ($this->isColumnModified(DamagesCarDamagesPeer::CREATED)) $criteria->add(DamagesCarDamagesPeer::CREATED, $this->created);
        if ($this->isColumnModified(DamagesCarDamagesPeer::MODIFIED)) $criteria->add(DamagesCarDamagesPeer::MODIFIED, $this->modified);

        return $criteria;
    }

    /**
     * Builds a Criteria object containing the primary key for this object.
     *
     * Unlike buildCriteria() this method includes the primary key values regardless
     * of whether or not they have been modified.
     *
     * @return Criteria The Criteria object containing value(s) for primary key(s).
     */
    public function buildPkeyCriteria()
    {
        $criteria = new Criteria(DamagesCarDamagesPeer::DATABASE_NAME);
        $criteria->add(DamagesCarDamagesPeer::ID, $this->id);

        return $criteria;
    }

    /**
     * Returns the primary key for this object (row).
     * @return int
     */
    public function getPrimaryKey()
    {
        return $this->getId();
    }

    /**
     * Generic method to set the primary key (id column).
     *
     * @param  int $key Primary key.
     * @return void
     */
    public function setPrimaryKey($key)
    {
        $this->setId($key);
    }

    /**
     * Returns true if the primary key for this object is null.
     * @return boolean
     */
    public function isPrimaryKeyNull()
    {

        return null === $this->getId();
    }

    /**
     * Sets contents of passed object to values from current object.
     *
     * If desired, this method can also make copies of all associated (fkey referrers)
     * objects.
     *
     * @param object $copyObj An object of DamagesCarDamages (or compatible) type.
     * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
     * @throws PropelException
     */
    public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
    {
        $copyObj->setCarDataId($this->getCarDataId());
        $copyObj->setStatusId($this->getStatusId());
        $copyObj->setDictPerpetratorId($this->getDictPerpetratorId());
        $copyObj->setProcessTypeId($this->getProcessTypeId());
        $copyObj->setRelatedCarDamage($this->getRelatedCarDamage());
        $copyObj->setLsId($this->getLsId());
        $copyObj->setOlId($this->getOlId());
        $copyObj->setDiscardId($this->getDiscardId());
        $copyObj->setDiscardDescription($this->getDiscardDescription());
        $copyObj->setDamageDate($this->getDamageDate());
        $copyObj->setDealerReportDate($this->getDealerReportDate());
        $copyObj->setPerpetratorReportDate($this->getPerpetratorReportDate());
        $copyObj->setDamagesDescription($this->getDamagesDescription());
        $copyObj->setDescription($this->getDescription());
        $copyObj->setCreated($this->getCreated());
        $copyObj->setModified($this->getModified());

        if ($deepCopy && !$this->startCopy) {
            // important: temporarily setNew(false) because this affects the behavior of
            // the getter/setter methods for fkey referrer objects.
            $copyObj->setNew(false);
            // store object hash to prevent cycle
            $this->startCopy = true;

            foreach ($this->getAttachmentss() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addAttachments($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getCarDamageChangeLogss() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addCarDamageChangeLogs($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getCarDamagessRelatedById() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addCarDamagesRelatedById($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getDamagess() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addDamages($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getEstimatedBudgetss() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addEstimatedBudgets($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getInvoicess() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addInvoices($relObj->copy($deepCopy));
                }
            }

            foreach ($this->getNotess() as $relObj) {
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
                    $copyObj->addNotes($relObj->copy($deepCopy));
                }
            }

            //unflag object copy
            $this->startCopy = false;
        } // if ($deepCopy)

        if ($makeNew) {
            $copyObj->setNew(true);
            $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
        }
    }

    /**
     * Makes a copy of this object that will be inserted as a new row in table when saved.
     * It creates a new object filling in the simple attributes, but skipping any primary
     * keys that are defined for the table.
     *
     * If desired, this method can also make copies of all associated (fkey referrers)
     * objects.
     *
     * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     * @return DamagesCarDamages Clone of current object.
     * @throws PropelException
     */
    public function copy($deepCopy = false)
    {
        // we use get_class(), because this might be a subclass
        $clazz = get_class($this);
        $copyObj = new $clazz();
        $this->copyInto($copyObj, $deepCopy);

        return $copyObj;
    }

    /**
     * Returns a peer instance associated with this om.
     *
     * Since Peer classes are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     *
     * @return DamagesCarDamagesPeer
     */
    public function getPeer()
    {
        if (self::$peer === null) {
            self::$peer = new DamagesCarDamagesPeer();
        }

        return self::$peer;
    }

    /**
     * Declares an association between this object and a DamagesCarDamages object.
     *
     * @param             DamagesCarDamages $v
     * @return DamagesCarDamages The current object (for fluent API support)
     * @throws PropelException
     */
    public function setCarDamagesRelatedByRelatedCarDamage(DamagesCarDamages $v = null)
    {
        if ($v === null) {
            $this->setRelatedCarDamage(NULL);
        } else {
            $this->setRelatedCarDamage($v->getId());
        }

        $this->aCarDamagesRelatedByRelatedCarDamage = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the DamagesCarDamages object, it will not be re-added.
        if ($v !== null) {
            $v->addCarDamagesRelatedById($this);
        }


        return $this;
    }


    /**
     * Get the associated DamagesCarDamages object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return DamagesCarDamages The associated DamagesCarDamages object.
     * @throws PropelException
     */
    public function getCarDamagesRelatedByRelatedCarDamage(PropelPDO $con = null)
    {
        if ($this->aCarDamagesRelatedByRelatedCarDamage === null && ($this->related_car_damage !== null)) {
            $this->aCarDamagesRelatedByRelatedCarDamage = DamagesCarDamagesQuery::create()->findPk($this->related_car_damage, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aCarDamagesRelatedByRelatedCarDamage->addCarDamagessRelatedById($this);
             */
        }

        return $this->aCarDamagesRelatedByRelatedCarDamage;
    }

    /**
     * Declares an association between this object and a DamagesDictStatuses object.
     *
     * @param             DamagesDictStatuses $v
     * @return DamagesCarDamages The current object (for fluent API support)
     * @throws PropelException
     */
    public function setDictStatuses(DamagesDictStatuses $v = null)
    {
        if ($v === null) {
            $this->setStatusId(NULL);
        } else {
            $this->setStatusId($v->getId());
        }

        $this->aDictStatuses = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the DamagesDictStatuses object, it will not be re-added.
        if ($v !== null) {
            $v->addCarDamages($this);
        }


        return $this;
    }


    /**
     * Get the associated DamagesDictStatuses object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return DamagesDictStatuses The associated DamagesDictStatuses object.
     * @throws PropelException
     */
    public function getDictStatuses(PropelPDO $con = null)
    {
        if ($this->aDictStatuses === null && ($this->status_id !== null)) {
            $this->aDictStatuses = DamagesDictStatusesQuery::create()->findPk($this->status_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aDictStatuses->addCarDamagess($this);
             */
        }

        return $this->aDictStatuses;
    }

    /**
     * Declares an association between this object and a DamagesCarData object.
     *
     * @param             DamagesCarData $v
     * @return DamagesCarDamages The current object (for fluent API support)
     * @throws PropelException
     */
    public function setCarData(DamagesCarData $v = null)
    {
        if ($v === null) {
            $this->setCarDataId(NULL);
        } else {
            $this->setCarDataId($v->getId());
        }

        $this->aCarData = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the DamagesCarData object, it will not be re-added.
        if ($v !== null) {
            $v->addCarDamages($this);
        }


        return $this;
    }


    /**
     * Get the associated DamagesCarData object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return DamagesCarData The associated DamagesCarData object.
     * @throws PropelException
     */
    public function getCarData(PropelPDO $con = null)
    {
        if ($this->aCarData === null && ($this->car_data_id !== null)) {
            $this->aCarData = DamagesCarDataQuery::create()->findPk($this->car_data_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aCarData->addCarDamagess($this);
             */
        }

        return $this->aCarData;
    }

    /**
     * Declares an association between this object and a DamagesUsers object.
     *
     * @param             DamagesUsers $v
     * @return DamagesCarDamages The current object (for fluent API support)
     * @throws PropelException
     */
    public function setUsersRelatedByLsId(DamagesUsers $v = null)
    {
        if ($v === null) {
            $this->setLsId(NULL);
        } else {
            $this->setLsId($v->getId());
        }

        $this->aUsersRelatedByLsId = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the DamagesUsers object, it will not be re-added.
        if ($v !== null) {
            $v->addCarDamagesRelatedByLsId($this);
        }


        return $this;
    }


    /**
     * Get the associated DamagesUsers object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return DamagesUsers The associated DamagesUsers object.
     * @throws PropelException
     */
    public function getUsersRelatedByLsId(PropelPDO $con = null)
    {
        if ($this->aUsersRelatedByLsId === null && ($this->ls_id !== null)) {
            $this->aUsersRelatedByLsId = DamagesUsersQuery::create()->findPk($this->ls_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aUsersRelatedByLsId->addCarDamagessRelatedByLsId($this);
             */
        }

        return $this->aUsersRelatedByLsId;
    }

    /**
     * Declares an association between this object and a DamagesUsers object.
     *
     * @param             DamagesUsers $v
     * @return DamagesCarDamages The current object (for fluent API support)
     * @throws PropelException
     */
    public function setUsersRelatedByOlId(DamagesUsers $v = null)
    {
        if ($v === null) {
            $this->setOlId(NULL);
        } else {
            $this->setOlId($v->getId());
        }

        $this->aUsersRelatedByOlId = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the DamagesUsers object, it will not be re-added.
        if ($v !== null) {
            $v->addCarDamagesRelatedByOlId($this);
        }


        return $this;
    }


    /**
     * Get the associated DamagesUsers object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return DamagesUsers The associated DamagesUsers object.
     * @throws PropelException
     */
    public function getUsersRelatedByOlId(PropelPDO $con = null)
    {
        if ($this->aUsersRelatedByOlId === null && ($this->ol_id !== null)) {
            $this->aUsersRelatedByOlId = DamagesUsersQuery::create()->findPk($this->ol_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aUsersRelatedByOlId->addCarDamagessRelatedByOlId($this);
             */
        }

        return $this->aUsersRelatedByOlId;
    }

    /**
     * Declares an association between this object and a DamagesDictDiscards object.
     *
     * @param             DamagesDictDiscards $v
     * @return DamagesCarDamages The current object (for fluent API support)
     * @throws PropelException
     */
    public function setDictDiscards(DamagesDictDiscards $v = null)
    {
        if ($v === null) {
            $this->setDiscardId(NULL);
        } else {
            $this->setDiscardId($v->getId());
        }

        $this->aDictDiscards = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the DamagesDictDiscards object, it will not be re-added.
        if ($v !== null) {
            $v->addCarDamages($this);
        }


        return $this;
    }


    /**
     * Get the associated DamagesDictDiscards object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return DamagesDictDiscards The associated DamagesDictDiscards object.
     * @throws PropelException
     */
    public function getDictDiscards(PropelPDO $con = null)
    {
        if ($this->aDictDiscards === null && ($this->discard_id !== null)) {
            $this->aDictDiscards = DamagesDictDiscardsQuery::create()->findPk($this->discard_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aDictDiscards->addCarDamagess($this);
             */
        }

        return $this->aDictDiscards;
    }

    /**
     * Declares an association between this object and a DamagesDictPerpetrators object.
     *
     * @param             DamagesDictPerpetrators $v
     * @return DamagesCarDamages The current object (for fluent API support)
     * @throws PropelException
     */
    public function setDictPerpetrators(DamagesDictPerpetrators $v = null)
    {
        if ($v === null) {
            $this->setDictPerpetratorId(NULL);
        } else {
            $this->setDictPerpetratorId($v->getId());
        }

        $this->aDictPerpetrators = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the DamagesDictPerpetrators object, it will not be re-added.
        if ($v !== null) {
            $v->addCarDamages($this);
        }


        return $this;
    }


    /**
     * Get the associated DamagesDictPerpetrators object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return DamagesDictPerpetrators The associated DamagesDictPerpetrators object.
     * @throws PropelException
     */
    public function getDictPerpetrators(PropelPDO $con = null)
    {
        if ($this->aDictPerpetrators === null && ($this->dict_perpetrator_id !== null)) {
            $this->aDictPerpetrators = DamagesDictPerpetratorsQuery::create()->findPk($this->dict_perpetrator_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aDictPerpetrators->addCarDamagess($this);
             */
        }

        return $this->aDictPerpetrators;
    }

    /**
     * Declares an association between this object and a DamagesProcessTypes object.
     *
     * @param             DamagesProcessTypes $v
     * @return DamagesCarDamages The current object (for fluent API support)
     * @throws PropelException
     */
    public function setProcessTypes(DamagesProcessTypes $v = null)
    {
        if ($v === null) {
            $this->setProcessTypeId(NULL);
        } else {
            $this->setProcessTypeId($v->getId());
        }

        $this->aProcessTypes = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the DamagesProcessTypes object, it will not be re-added.
        if ($v !== null) {
            $v->addCarDamages($this);
        }


        return $this;
    }


    /**
     * Get the associated DamagesProcessTypes object
     *
     * @param PropelPDO $con Optional Connection object.
     * @return DamagesProcessTypes The associated DamagesProcessTypes object.
     * @throws PropelException
     */
    public function getProcessTypes(PropelPDO $con = null)
    {
        if ($this->aProcessTypes === null && ($this->process_type_id !== null)) {
            $this->aProcessTypes = DamagesProcessTypesQuery::create()->findPk($this->process_type_id, $con);
            /* The following can be used additionally to
                guarantee the related object contains a reference
                to this object.  This level of coupling may, however, be
                undesirable since it could result in an only partially populated collection
                in the referenced object.
                $this->aProcessTypes->addCarDamagess($this);
             */
        }

        return $this->aProcessTypes;
    }


    /**
     * Initializes a collection based on the name of a relation.
     * Avoids crafting an 'init[$relationName]s' method name
     * that wouldn't work when StandardEnglishPluralizer is used.
     *
     * @param string $relationName The name of the relation to initialize
     * @return void
     */
    public function initRelation($relationName)
    {
        if ('Attachments' == $relationName) {
            $this->initAttachmentss();
        }
        if ('CarDamageChangeLogs' == $relationName) {
            $this->initCarDamageChangeLogss();
        }
        if ('CarDamagesRelatedById' == $relationName) {
            $this->initCarDamagessRelatedById();
        }
        if ('Damages' == $relationName) {
            $this->initDamagess();
        }
        if ('EstimatedBudgets' == $relationName) {
            $this->initEstimatedBudgetss();
        }
        if ('Invoices' == $relationName) {
            $this->initInvoicess();
        }
        if ('Notes' == $relationName) {
            $this->initNotess();
        }
    }

    /**
     * Clears out the collAttachmentss collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addAttachmentss()
     */
    public function clearAttachmentss()
    {
        $this->collAttachmentss = null; // important to set this to null since that means it is uninitialized
        $this->collAttachmentssPartial = null;
    }

    /**
     * reset is the collAttachmentss collection loaded partially
     *
     * @return void
     */
    public function resetPartialAttachmentss($v = true)
    {
        $this->collAttachmentssPartial = $v;
    }

    /**
     * Initializes the collAttachmentss collection.
     *
     * By default this just sets the collAttachmentss collection to an empty array (like clearcollAttachmentss());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initAttachmentss($overrideExisting = true)
    {
        if (null !== $this->collAttachmentss && !$overrideExisting) {
            return;
        }
        $this->collAttachmentss = new PropelObjectCollection();
        $this->collAttachmentss->setModel('DamagesAttachments');
    }

    /**
     * Gets an array of DamagesAttachments objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this DamagesCarDamages is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|DamagesAttachments[] List of DamagesAttachments objects
     * @throws PropelException
     */
    public function getAttachmentss($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collAttachmentssPartial && !$this->isNew();
        if (null === $this->collAttachmentss || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collAttachmentss) {
                // return empty collection
                $this->initAttachmentss();
            } else {
                $collAttachmentss = DamagesAttachmentsQuery::create(null, $criteria)
                    ->filterByCarDamages($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collAttachmentssPartial && count($collAttachmentss)) {
                      $this->initAttachmentss(false);

                      foreach($collAttachmentss as $obj) {
                        if (false == $this->collAttachmentss->contains($obj)) {
                          $this->collAttachmentss->append($obj);
                        }
                      }

                      $this->collAttachmentssPartial = true;
                    }

                    return $collAttachmentss;
                }

                if($partial && $this->collAttachmentss) {
                    foreach($this->collAttachmentss as $obj) {
                        if($obj->isNew()) {
                            $collAttachmentss[] = $obj;
                        }
                    }
                }

                $this->collAttachmentss = $collAttachmentss;
                $this->collAttachmentssPartial = false;
            }
        }

        return $this->collAttachmentss;
    }

    /**
     * Sets a collection of Attachments objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $attachmentss A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setAttachmentss(PropelCollection $attachmentss, PropelPDO $con = null)
    {
        $this->attachmentssScheduledForDeletion = $this->getAttachmentss(new Criteria(), $con)->diff($attachmentss);

        foreach ($this->attachmentssScheduledForDeletion as $attachmentsRemoved) {
            $attachmentsRemoved->setCarDamages(null);
        }

        $this->collAttachmentss = null;
        foreach ($attachmentss as $attachments) {
            $this->addAttachments($attachments);
        }

        $this->collAttachmentss = $attachmentss;
        $this->collAttachmentssPartial = false;
    }

    /**
     * Returns the number of related DamagesAttachments objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related DamagesAttachments objects.
     * @throws PropelException
     */
    public function countAttachmentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collAttachmentssPartial && !$this->isNew();
        if (null === $this->collAttachmentss || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collAttachmentss) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getAttachmentss());
                }
                $query = DamagesAttachmentsQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByCarDamages($this)
                    ->count($con);
            }
        } else {
            return count($this->collAttachmentss);
        }
    }

    /**
     * Method called to associate a DamagesAttachments object to this object
     * through the DamagesAttachments foreign key attribute.
     *
     * @param    DamagesAttachments $l DamagesAttachments
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function addAttachments(DamagesAttachments $l)
    {
        if ($this->collAttachmentss === null) {
            $this->initAttachmentss();
            $this->collAttachmentssPartial = true;
        }
        if (!$this->collAttachmentss->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddAttachments($l);
        }

        return $this;
    }

    /**
     * @param	Attachments $attachments The attachments object to add.
     */
    protected function doAddAttachments($attachments)
    {
        $this->collAttachmentss[]= $attachments;
        $attachments->setCarDamages($this);
    }

    /**
     * @param	Attachments $attachments The attachments object to remove.
     */
    public function removeAttachments($attachments)
    {
        if ($this->getAttachmentss()->contains($attachments)) {
            $this->collAttachmentss->remove($this->collAttachmentss->search($attachments));
            if (null === $this->attachmentssScheduledForDeletion) {
                $this->attachmentssScheduledForDeletion = clone $this->collAttachmentss;
                $this->attachmentssScheduledForDeletion->clear();
            }
            $this->attachmentssScheduledForDeletion[]= $attachments;
            $attachments->setCarDamages(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related Attachmentss from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesAttachments[] List of DamagesAttachments objects
     */
    public function getAttachmentssJoinDictAttachmentTypes($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesAttachmentsQuery::create(null, $criteria);
        $query->joinWith('DictAttachmentTypes', $join_behavior);

        return $this->getAttachmentss($query, $con);
    }

    /**
     * Clears out the collCarDamageChangeLogss collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addCarDamageChangeLogss()
     */
    public function clearCarDamageChangeLogss()
    {
        $this->collCarDamageChangeLogss = null; // important to set this to null since that means it is uninitialized
        $this->collCarDamageChangeLogssPartial = null;
    }

    /**
     * reset is the collCarDamageChangeLogss collection loaded partially
     *
     * @return void
     */
    public function resetPartialCarDamageChangeLogss($v = true)
    {
        $this->collCarDamageChangeLogssPartial = $v;
    }

    /**
     * Initializes the collCarDamageChangeLogss collection.
     *
     * By default this just sets the collCarDamageChangeLogss collection to an empty array (like clearcollCarDamageChangeLogss());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initCarDamageChangeLogss($overrideExisting = true)
    {
        if (null !== $this->collCarDamageChangeLogss && !$overrideExisting) {
            return;
        }
        $this->collCarDamageChangeLogss = new PropelObjectCollection();
        $this->collCarDamageChangeLogss->setModel('DamagesCarDamageChangeLogs');
    }

    /**
     * Gets an array of DamagesCarDamageChangeLogs objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this DamagesCarDamages is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|DamagesCarDamageChangeLogs[] List of DamagesCarDamageChangeLogs objects
     * @throws PropelException
     */
    public function getCarDamageChangeLogss($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collCarDamageChangeLogssPartial && !$this->isNew();
        if (null === $this->collCarDamageChangeLogss || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collCarDamageChangeLogss) {
                // return empty collection
                $this->initCarDamageChangeLogss();
            } else {
                $collCarDamageChangeLogss = DamagesCarDamageChangeLogsQuery::create(null, $criteria)
                    ->filterByCarDamages($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collCarDamageChangeLogssPartial && count($collCarDamageChangeLogss)) {
                      $this->initCarDamageChangeLogss(false);

                      foreach($collCarDamageChangeLogss as $obj) {
                        if (false == $this->collCarDamageChangeLogss->contains($obj)) {
                          $this->collCarDamageChangeLogss->append($obj);
                        }
                      }

                      $this->collCarDamageChangeLogssPartial = true;
                    }

                    return $collCarDamageChangeLogss;
                }

                if($partial && $this->collCarDamageChangeLogss) {
                    foreach($this->collCarDamageChangeLogss as $obj) {
                        if($obj->isNew()) {
                            $collCarDamageChangeLogss[] = $obj;
                        }
                    }
                }

                $this->collCarDamageChangeLogss = $collCarDamageChangeLogss;
                $this->collCarDamageChangeLogssPartial = false;
            }
        }

        return $this->collCarDamageChangeLogss;
    }

    /**
     * Sets a collection of CarDamageChangeLogs objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $carDamageChangeLogss A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setCarDamageChangeLogss(PropelCollection $carDamageChangeLogss, PropelPDO $con = null)
    {
        $this->carDamageChangeLogssScheduledForDeletion = $this->getCarDamageChangeLogss(new Criteria(), $con)->diff($carDamageChangeLogss);

        foreach ($this->carDamageChangeLogssScheduledForDeletion as $carDamageChangeLogsRemoved) {
            $carDamageChangeLogsRemoved->setCarDamages(null);
        }

        $this->collCarDamageChangeLogss = null;
        foreach ($carDamageChangeLogss as $carDamageChangeLogs) {
            $this->addCarDamageChangeLogs($carDamageChangeLogs);
        }

        $this->collCarDamageChangeLogss = $carDamageChangeLogss;
        $this->collCarDamageChangeLogssPartial = false;
    }

    /**
     * Returns the number of related DamagesCarDamageChangeLogs objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related DamagesCarDamageChangeLogs objects.
     * @throws PropelException
     */
    public function countCarDamageChangeLogss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collCarDamageChangeLogssPartial && !$this->isNew();
        if (null === $this->collCarDamageChangeLogss || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collCarDamageChangeLogss) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getCarDamageChangeLogss());
                }
                $query = DamagesCarDamageChangeLogsQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByCarDamages($this)
                    ->count($con);
            }
        } else {
            return count($this->collCarDamageChangeLogss);
        }
    }

    /**
     * Method called to associate a DamagesCarDamageChangeLogs object to this object
     * through the DamagesCarDamageChangeLogs foreign key attribute.
     *
     * @param    DamagesCarDamageChangeLogs $l DamagesCarDamageChangeLogs
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function addCarDamageChangeLogs(DamagesCarDamageChangeLogs $l)
    {
        if ($this->collCarDamageChangeLogss === null) {
            $this->initCarDamageChangeLogss();
            $this->collCarDamageChangeLogssPartial = true;
        }
        if (!$this->collCarDamageChangeLogss->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddCarDamageChangeLogs($l);
        }

        return $this;
    }

    /**
     * @param	CarDamageChangeLogs $carDamageChangeLogs The carDamageChangeLogs object to add.
     */
    protected function doAddCarDamageChangeLogs($carDamageChangeLogs)
    {
        $this->collCarDamageChangeLogss[]= $carDamageChangeLogs;
        $carDamageChangeLogs->setCarDamages($this);
    }

    /**
     * @param	CarDamageChangeLogs $carDamageChangeLogs The carDamageChangeLogs object to remove.
     */
    public function removeCarDamageChangeLogs($carDamageChangeLogs)
    {
        if ($this->getCarDamageChangeLogss()->contains($carDamageChangeLogs)) {
            $this->collCarDamageChangeLogss->remove($this->collCarDamageChangeLogss->search($carDamageChangeLogs));
            if (null === $this->carDamageChangeLogssScheduledForDeletion) {
                $this->carDamageChangeLogssScheduledForDeletion = clone $this->collCarDamageChangeLogss;
                $this->carDamageChangeLogssScheduledForDeletion->clear();
            }
            $this->carDamageChangeLogssScheduledForDeletion[]= $carDamageChangeLogs;
            $carDamageChangeLogs->setCarDamages(null);
        }
    }

    /**
     * Clears out the collCarDamagessRelatedById collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addCarDamagessRelatedById()
     */
    public function clearCarDamagessRelatedById()
    {
        $this->collCarDamagessRelatedById = null; // important to set this to null since that means it is uninitialized
        $this->collCarDamagessRelatedByIdPartial = null;
    }

    /**
     * reset is the collCarDamagessRelatedById collection loaded partially
     *
     * @return void
     */
    public function resetPartialCarDamagessRelatedById($v = true)
    {
        $this->collCarDamagessRelatedByIdPartial = $v;
    }

    /**
     * Initializes the collCarDamagessRelatedById collection.
     *
     * By default this just sets the collCarDamagessRelatedById collection to an empty array (like clearcollCarDamagessRelatedById());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initCarDamagessRelatedById($overrideExisting = true)
    {
        if (null !== $this->collCarDamagessRelatedById && !$overrideExisting) {
            return;
        }
        $this->collCarDamagessRelatedById = new PropelObjectCollection();
        $this->collCarDamagessRelatedById->setModel('DamagesCarDamages');
    }

    /**
     * Gets an array of DamagesCarDamages objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this DamagesCarDamages is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|DamagesCarDamages[] List of DamagesCarDamages objects
     * @throws PropelException
     */
    public function getCarDamagessRelatedById($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collCarDamagessRelatedByIdPartial && !$this->isNew();
        if (null === $this->collCarDamagessRelatedById || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collCarDamagessRelatedById) {
                // return empty collection
                $this->initCarDamagessRelatedById();
            } else {
                $collCarDamagessRelatedById = DamagesCarDamagesQuery::create(null, $criteria)
                    ->filterByCarDamagesRelatedByRelatedCarDamage($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collCarDamagessRelatedByIdPartial && count($collCarDamagessRelatedById)) {
                      $this->initCarDamagessRelatedById(false);

                      foreach($collCarDamagessRelatedById as $obj) {
                        if (false == $this->collCarDamagessRelatedById->contains($obj)) {
                          $this->collCarDamagessRelatedById->append($obj);
                        }
                      }

                      $this->collCarDamagessRelatedByIdPartial = true;
                    }

                    return $collCarDamagessRelatedById;
                }

                if($partial && $this->collCarDamagessRelatedById) {
                    foreach($this->collCarDamagessRelatedById as $obj) {
                        if($obj->isNew()) {
                            $collCarDamagessRelatedById[] = $obj;
                        }
                    }
                }

                $this->collCarDamagessRelatedById = $collCarDamagessRelatedById;
                $this->collCarDamagessRelatedByIdPartial = false;
            }
        }

        return $this->collCarDamagessRelatedById;
    }

    /**
     * Sets a collection of CarDamagesRelatedById objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $carDamagessRelatedById A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setCarDamagessRelatedById(PropelCollection $carDamagessRelatedById, PropelPDO $con = null)
    {
        $this->carDamagessRelatedByIdScheduledForDeletion = $this->getCarDamagessRelatedById(new Criteria(), $con)->diff($carDamagessRelatedById);

        foreach ($this->carDamagessRelatedByIdScheduledForDeletion as $carDamagesRelatedByIdRemoved) {
            $carDamagesRelatedByIdRemoved->setCarDamagesRelatedByRelatedCarDamage(null);
        }

        $this->collCarDamagessRelatedById = null;
        foreach ($carDamagessRelatedById as $carDamagesRelatedById) {
            $this->addCarDamagesRelatedById($carDamagesRelatedById);
        }

        $this->collCarDamagessRelatedById = $carDamagessRelatedById;
        $this->collCarDamagessRelatedByIdPartial = false;
    }

    /**
     * Returns the number of related DamagesCarDamages objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related DamagesCarDamages objects.
     * @throws PropelException
     */
    public function countCarDamagessRelatedById(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collCarDamagessRelatedByIdPartial && !$this->isNew();
        if (null === $this->collCarDamagessRelatedById || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collCarDamagessRelatedById) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getCarDamagessRelatedById());
                }
                $query = DamagesCarDamagesQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByCarDamagesRelatedByRelatedCarDamage($this)
                    ->count($con);
            }
        } else {
            return count($this->collCarDamagessRelatedById);
        }
    }

    /**
     * Method called to associate a DamagesCarDamages object to this object
     * through the DamagesCarDamages foreign key attribute.
     *
     * @param    DamagesCarDamages $l DamagesCarDamages
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function addCarDamagesRelatedById(DamagesCarDamages $l)
    {
        if ($this->collCarDamagessRelatedById === null) {
            $this->initCarDamagessRelatedById();
            $this->collCarDamagessRelatedByIdPartial = true;
        }
        if (!$this->collCarDamagessRelatedById->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddCarDamagesRelatedById($l);
        }

        return $this;
    }

    /**
     * @param	CarDamagesRelatedById $carDamagesRelatedById The carDamagesRelatedById object to add.
     */
    protected function doAddCarDamagesRelatedById($carDamagesRelatedById)
    {
        $this->collCarDamagessRelatedById[]= $carDamagesRelatedById;
        $carDamagesRelatedById->setCarDamagesRelatedByRelatedCarDamage($this);
    }

    /**
     * @param	CarDamagesRelatedById $carDamagesRelatedById The carDamagesRelatedById object to remove.
     */
    public function removeCarDamagesRelatedById($carDamagesRelatedById)
    {
        if ($this->getCarDamagessRelatedById()->contains($carDamagesRelatedById)) {
            $this->collCarDamagessRelatedById->remove($this->collCarDamagessRelatedById->search($carDamagesRelatedById));
            if (null === $this->carDamagessRelatedByIdScheduledForDeletion) {
                $this->carDamagessRelatedByIdScheduledForDeletion = clone $this->collCarDamagessRelatedById;
                $this->carDamagessRelatedByIdScheduledForDeletion->clear();
            }
            $this->carDamagessRelatedByIdScheduledForDeletion[]= $carDamagesRelatedById;
            $carDamagesRelatedById->setCarDamagesRelatedByRelatedCarDamage(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related CarDamagessRelatedById from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesCarDamages[] List of DamagesCarDamages objects
     */
    public function getCarDamagessRelatedByIdJoinDictStatuses($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesCarDamagesQuery::create(null, $criteria);
        $query->joinWith('DictStatuses', $join_behavior);

        return $this->getCarDamagessRelatedById($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related CarDamagessRelatedById from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesCarDamages[] List of DamagesCarDamages objects
     */
    public function getCarDamagessRelatedByIdJoinCarData($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesCarDamagesQuery::create(null, $criteria);
        $query->joinWith('CarData', $join_behavior);

        return $this->getCarDamagessRelatedById($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related CarDamagessRelatedById from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesCarDamages[] List of DamagesCarDamages objects
     */
    public function getCarDamagessRelatedByIdJoinUsersRelatedByLsId($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesCarDamagesQuery::create(null, $criteria);
        $query->joinWith('UsersRelatedByLsId', $join_behavior);

        return $this->getCarDamagessRelatedById($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related CarDamagessRelatedById from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesCarDamages[] List of DamagesCarDamages objects
     */
    public function getCarDamagessRelatedByIdJoinUsersRelatedByOlId($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesCarDamagesQuery::create(null, $criteria);
        $query->joinWith('UsersRelatedByOlId', $join_behavior);

        return $this->getCarDamagessRelatedById($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related CarDamagessRelatedById from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesCarDamages[] List of DamagesCarDamages objects
     */
    public function getCarDamagessRelatedByIdJoinDictDiscards($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesCarDamagesQuery::create(null, $criteria);
        $query->joinWith('DictDiscards', $join_behavior);

        return $this->getCarDamagessRelatedById($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related CarDamagessRelatedById from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesCarDamages[] List of DamagesCarDamages objects
     */
    public function getCarDamagessRelatedByIdJoinDictPerpetrators($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesCarDamagesQuery::create(null, $criteria);
        $query->joinWith('DictPerpetrators', $join_behavior);

        return $this->getCarDamagessRelatedById($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related CarDamagessRelatedById from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesCarDamages[] List of DamagesCarDamages objects
     */
    public function getCarDamagessRelatedByIdJoinProcessTypes($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesCarDamagesQuery::create(null, $criteria);
        $query->joinWith('ProcessTypes', $join_behavior);

        return $this->getCarDamagessRelatedById($query, $con);
    }

    /**
     * Clears out the collDamagess collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addDamagess()
     */
    public function clearDamagess()
    {
        $this->collDamagess = null; // important to set this to null since that means it is uninitialized
        $this->collDamagessPartial = null;
    }

    /**
     * reset is the collDamagess collection loaded partially
     *
     * @return void
     */
    public function resetPartialDamagess($v = true)
    {
        $this->collDamagessPartial = $v;
    }

    /**
     * Initializes the collDamagess collection.
     *
     * By default this just sets the collDamagess collection to an empty array (like clearcollDamagess());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initDamagess($overrideExisting = true)
    {
        if (null !== $this->collDamagess && !$overrideExisting) {
            return;
        }
        $this->collDamagess = new PropelObjectCollection();
        $this->collDamagess->setModel('DamagesDamages');
    }

    /**
     * Gets an array of DamagesDamages objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this DamagesCarDamages is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|DamagesDamages[] List of DamagesDamages objects
     * @throws PropelException
     */
    public function getDamagess($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collDamagessPartial && !$this->isNew();
        if (null === $this->collDamagess || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collDamagess) {
                // return empty collection
                $this->initDamagess();
            } else {
                $collDamagess = DamagesDamagesQuery::create(null, $criteria)
                    ->filterByCarDamages($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collDamagessPartial && count($collDamagess)) {
                      $this->initDamagess(false);

                      foreach($collDamagess as $obj) {
                        if (false == $this->collDamagess->contains($obj)) {
                          $this->collDamagess->append($obj);
                        }
                      }

                      $this->collDamagessPartial = true;
                    }

                    return $collDamagess;
                }

                if($partial && $this->collDamagess) {
                    foreach($this->collDamagess as $obj) {
                        if($obj->isNew()) {
                            $collDamagess[] = $obj;
                        }
                    }
                }

                $this->collDamagess = $collDamagess;
                $this->collDamagessPartial = false;
            }
        }

        return $this->collDamagess;
    }

    /**
     * Sets a collection of Damages objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $damagess A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setDamagess(PropelCollection $damagess, PropelPDO $con = null)
    {
        $this->damagessScheduledForDeletion = $this->getDamagess(new Criteria(), $con)->diff($damagess);

        foreach ($this->damagessScheduledForDeletion as $damagesRemoved) {
            $damagesRemoved->setCarDamages(null);
        }

        $this->collDamagess = null;
        foreach ($damagess as $damages) {
            $this->addDamages($damages);
        }

        $this->collDamagess = $damagess;
        $this->collDamagessPartial = false;
    }

    /**
     * Returns the number of related DamagesDamages objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related DamagesDamages objects.
     * @throws PropelException
     */
    public function countDamagess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collDamagessPartial && !$this->isNew();
        if (null === $this->collDamagess || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collDamagess) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getDamagess());
                }
                $query = DamagesDamagesQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByCarDamages($this)
                    ->count($con);
            }
        } else {
            return count($this->collDamagess);
        }
    }

    /**
     * Method called to associate a DamagesDamages object to this object
     * through the DamagesDamages foreign key attribute.
     *
     * @param    DamagesDamages $l DamagesDamages
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function addDamages(DamagesDamages $l)
    {
        if ($this->collDamagess === null) {
            $this->initDamagess();
            $this->collDamagessPartial = true;
        }
        if (!$this->collDamagess->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddDamages($l);
        }

        return $this;
    }

    /**
     * @param	Damages $damages The damages object to add.
     */
    protected function doAddDamages($damages)
    {
        $this->collDamagess[]= $damages;
        $damages->setCarDamages($this);
    }

    /**
     * @param	Damages $damages The damages object to remove.
     */
    public function removeDamages($damages)
    {
        if ($this->getDamagess()->contains($damages)) {
            $this->collDamagess->remove($this->collDamagess->search($damages));
            if (null === $this->damagessScheduledForDeletion) {
                $this->damagessScheduledForDeletion = clone $this->collDamagess;
                $this->damagessScheduledForDeletion->clear();
            }
            $this->damagessScheduledForDeletion[]= $damages;
            $damages->setCarDamages(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related Damagess from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesDamages[] List of DamagesDamages objects
     */
    public function getDamagessJoinDictDamageTypes($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesDamagesQuery::create(null, $criteria);
        $query->joinWith('DictDamageTypes', $join_behavior);

        return $this->getDamagess($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related Damagess from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesDamages[] List of DamagesDamages objects
     */
    public function getDamagessJoinDictDamageSpots($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesDamagesQuery::create(null, $criteria);
        $query->joinWith('DictDamageSpots', $join_behavior);

        return $this->getDamagess($query, $con);
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related Damagess from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesDamages[] List of DamagesDamages objects
     */
    public function getDamagessJoinDictDamageScale($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesDamagesQuery::create(null, $criteria);
        $query->joinWith('DictDamageScale', $join_behavior);

        return $this->getDamagess($query, $con);
    }

    /**
     * Clears out the collEstimatedBudgetss collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addEstimatedBudgetss()
     */
    public function clearEstimatedBudgetss()
    {
        $this->collEstimatedBudgetss = null; // important to set this to null since that means it is uninitialized
        $this->collEstimatedBudgetssPartial = null;
    }

    /**
     * reset is the collEstimatedBudgetss collection loaded partially
     *
     * @return void
     */
    public function resetPartialEstimatedBudgetss($v = true)
    {
        $this->collEstimatedBudgetssPartial = $v;
    }

    /**
     * Initializes the collEstimatedBudgetss collection.
     *
     * By default this just sets the collEstimatedBudgetss collection to an empty array (like clearcollEstimatedBudgetss());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initEstimatedBudgetss($overrideExisting = true)
    {
        if (null !== $this->collEstimatedBudgetss && !$overrideExisting) {
            return;
        }
        $this->collEstimatedBudgetss = new PropelObjectCollection();
        $this->collEstimatedBudgetss->setModel('DamagesEstimatedBudgets');
    }

    /**
     * Gets an array of DamagesEstimatedBudgets objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this DamagesCarDamages is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|DamagesEstimatedBudgets[] List of DamagesEstimatedBudgets objects
     * @throws PropelException
     */
    public function getEstimatedBudgetss($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collEstimatedBudgetssPartial && !$this->isNew();
        if (null === $this->collEstimatedBudgetss || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collEstimatedBudgetss) {
                // return empty collection
                $this->initEstimatedBudgetss();
            } else {
                $collEstimatedBudgetss = DamagesEstimatedBudgetsQuery::create(null, $criteria)
                    ->filterByCarDamages($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collEstimatedBudgetssPartial && count($collEstimatedBudgetss)) {
                      $this->initEstimatedBudgetss(false);

                      foreach($collEstimatedBudgetss as $obj) {
                        if (false == $this->collEstimatedBudgetss->contains($obj)) {
                          $this->collEstimatedBudgetss->append($obj);
                        }
                      }

                      $this->collEstimatedBudgetssPartial = true;
                    }

                    return $collEstimatedBudgetss;
                }

                if($partial && $this->collEstimatedBudgetss) {
                    foreach($this->collEstimatedBudgetss as $obj) {
                        if($obj->isNew()) {
                            $collEstimatedBudgetss[] = $obj;
                        }
                    }
                }

                $this->collEstimatedBudgetss = $collEstimatedBudgetss;
                $this->collEstimatedBudgetssPartial = false;
            }
        }

        return $this->collEstimatedBudgetss;
    }

    /**
     * Sets a collection of EstimatedBudgets objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $estimatedBudgetss A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setEstimatedBudgetss(PropelCollection $estimatedBudgetss, PropelPDO $con = null)
    {
        $this->estimatedBudgetssScheduledForDeletion = $this->getEstimatedBudgetss(new Criteria(), $con)->diff($estimatedBudgetss);

        foreach ($this->estimatedBudgetssScheduledForDeletion as $estimatedBudgetsRemoved) {
            $estimatedBudgetsRemoved->setCarDamages(null);
        }

        $this->collEstimatedBudgetss = null;
        foreach ($estimatedBudgetss as $estimatedBudgets) {
            $this->addEstimatedBudgets($estimatedBudgets);
        }

        $this->collEstimatedBudgetss = $estimatedBudgetss;
        $this->collEstimatedBudgetssPartial = false;
    }

    /**
     * Returns the number of related DamagesEstimatedBudgets objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related DamagesEstimatedBudgets objects.
     * @throws PropelException
     */
    public function countEstimatedBudgetss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collEstimatedBudgetssPartial && !$this->isNew();
        if (null === $this->collEstimatedBudgetss || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collEstimatedBudgetss) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getEstimatedBudgetss());
                }
                $query = DamagesEstimatedBudgetsQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByCarDamages($this)
                    ->count($con);
            }
        } else {
            return count($this->collEstimatedBudgetss);
        }
    }

    /**
     * Method called to associate a DamagesEstimatedBudgets object to this object
     * through the DamagesEstimatedBudgets foreign key attribute.
     *
     * @param    DamagesEstimatedBudgets $l DamagesEstimatedBudgets
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function addEstimatedBudgets(DamagesEstimatedBudgets $l)
    {
        if ($this->collEstimatedBudgetss === null) {
            $this->initEstimatedBudgetss();
            $this->collEstimatedBudgetssPartial = true;
        }
        if (!$this->collEstimatedBudgetss->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddEstimatedBudgets($l);
        }

        return $this;
    }

    /**
     * @param	EstimatedBudgets $estimatedBudgets The estimatedBudgets object to add.
     */
    protected function doAddEstimatedBudgets($estimatedBudgets)
    {
        $this->collEstimatedBudgetss[]= $estimatedBudgets;
        $estimatedBudgets->setCarDamages($this);
    }

    /**
     * @param	EstimatedBudgets $estimatedBudgets The estimatedBudgets object to remove.
     */
    public function removeEstimatedBudgets($estimatedBudgets)
    {
        if ($this->getEstimatedBudgetss()->contains($estimatedBudgets)) {
            $this->collEstimatedBudgetss->remove($this->collEstimatedBudgetss->search($estimatedBudgets));
            if (null === $this->estimatedBudgetssScheduledForDeletion) {
                $this->estimatedBudgetssScheduledForDeletion = clone $this->collEstimatedBudgetss;
                $this->estimatedBudgetssScheduledForDeletion->clear();
            }
            $this->estimatedBudgetssScheduledForDeletion[]= $estimatedBudgets;
            $estimatedBudgets->setCarDamages(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related EstimatedBudgetss from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesEstimatedBudgets[] List of DamagesEstimatedBudgets objects
     */
    public function getEstimatedBudgetssJoinAttachments($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesEstimatedBudgetsQuery::create(null, $criteria);
        $query->joinWith('Attachments', $join_behavior);

        return $this->getEstimatedBudgetss($query, $con);
    }

    /**
     * Clears out the collInvoicess collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addInvoicess()
     */
    public function clearInvoicess()
    {
        $this->collInvoicess = null; // important to set this to null since that means it is uninitialized
        $this->collInvoicessPartial = null;
    }

    /**
     * reset is the collInvoicess collection loaded partially
     *
     * @return void
     */
    public function resetPartialInvoicess($v = true)
    {
        $this->collInvoicessPartial = $v;
    }

    /**
     * Initializes the collInvoicess collection.
     *
     * By default this just sets the collInvoicess collection to an empty array (like clearcollInvoicess());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initInvoicess($overrideExisting = true)
    {
        if (null !== $this->collInvoicess && !$overrideExisting) {
            return;
        }
        $this->collInvoicess = new PropelObjectCollection();
        $this->collInvoicess->setModel('DamagesInvoices');
    }

    /**
     * Gets an array of DamagesInvoices objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this DamagesCarDamages is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|DamagesInvoices[] List of DamagesInvoices objects
     * @throws PropelException
     */
    public function getInvoicess($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collInvoicessPartial && !$this->isNew();
        if (null === $this->collInvoicess || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collInvoicess) {
                // return empty collection
                $this->initInvoicess();
            } else {
                $collInvoicess = DamagesInvoicesQuery::create(null, $criteria)
                    ->filterByCarDamages($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collInvoicessPartial && count($collInvoicess)) {
                      $this->initInvoicess(false);

                      foreach($collInvoicess as $obj) {
                        if (false == $this->collInvoicess->contains($obj)) {
                          $this->collInvoicess->append($obj);
                        }
                      }

                      $this->collInvoicessPartial = true;
                    }

                    return $collInvoicess;
                }

                if($partial && $this->collInvoicess) {
                    foreach($this->collInvoicess as $obj) {
                        if($obj->isNew()) {
                            $collInvoicess[] = $obj;
                        }
                    }
                }

                $this->collInvoicess = $collInvoicess;
                $this->collInvoicessPartial = false;
            }
        }

        return $this->collInvoicess;
    }

    /**
     * Sets a collection of Invoices objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $invoicess A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setInvoicess(PropelCollection $invoicess, PropelPDO $con = null)
    {
        $this->invoicessScheduledForDeletion = $this->getInvoicess(new Criteria(), $con)->diff($invoicess);

        foreach ($this->invoicessScheduledForDeletion as $invoicesRemoved) {
            $invoicesRemoved->setCarDamages(null);
        }

        $this->collInvoicess = null;
        foreach ($invoicess as $invoices) {
            $this->addInvoices($invoices);
        }

        $this->collInvoicess = $invoicess;
        $this->collInvoicessPartial = false;
    }

    /**
     * Returns the number of related DamagesInvoices objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related DamagesInvoices objects.
     * @throws PropelException
     */
    public function countInvoicess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collInvoicessPartial && !$this->isNew();
        if (null === $this->collInvoicess || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collInvoicess) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getInvoicess());
                }
                $query = DamagesInvoicesQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByCarDamages($this)
                    ->count($con);
            }
        } else {
            return count($this->collInvoicess);
        }
    }

    /**
     * Method called to associate a DamagesInvoices object to this object
     * through the DamagesInvoices foreign key attribute.
     *
     * @param    DamagesInvoices $l DamagesInvoices
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function addInvoices(DamagesInvoices $l)
    {
        if ($this->collInvoicess === null) {
            $this->initInvoicess();
            $this->collInvoicessPartial = true;
        }
        if (!$this->collInvoicess->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddInvoices($l);
        }

        return $this;
    }

    /**
     * @param	Invoices $invoices The invoices object to add.
     */
    protected function doAddInvoices($invoices)
    {
        $this->collInvoicess[]= $invoices;
        $invoices->setCarDamages($this);
    }

    /**
     * @param	Invoices $invoices The invoices object to remove.
     */
    public function removeInvoices($invoices)
    {
        if ($this->getInvoicess()->contains($invoices)) {
            $this->collInvoicess->remove($this->collInvoicess->search($invoices));
            if (null === $this->invoicessScheduledForDeletion) {
                $this->invoicessScheduledForDeletion = clone $this->collInvoicess;
                $this->invoicessScheduledForDeletion->clear();
            }
            $this->invoicessScheduledForDeletion[]= $invoices;
            $invoices->setCarDamages(null);
        }
    }

    /**
     * Clears out the collNotess collection
     *
     * This does not modify the database; however, it will remove any associated objects, causing
     * them to be refetched by subsequent calls to accessor method.
     *
     * @return void
     * @see        addNotess()
     */
    public function clearNotess()
    {
        $this->collNotess = null; // important to set this to null since that means it is uninitialized
        $this->collNotessPartial = null;
    }

    /**
     * reset is the collNotess collection loaded partially
     *
     * @return void
     */
    public function resetPartialNotess($v = true)
    {
        $this->collNotessPartial = $v;
    }

    /**
     * Initializes the collNotess collection.
     *
     * By default this just sets the collNotess collection to an empty array (like clearcollNotess());
     * however, you may wish to override this method in your stub class to provide setting appropriate
     * to your application -- for example, setting the initial array to the values stored in database.
     *
     * @param boolean $overrideExisting If set to true, the method call initializes
     *                                        the collection even if it is not empty
     *
     * @return void
     */
    public function initNotess($overrideExisting = true)
    {
        if (null !== $this->collNotess && !$overrideExisting) {
            return;
        }
        $this->collNotess = new PropelObjectCollection();
        $this->collNotess->setModel('DamagesNotes');
    }

    /**
     * Gets an array of DamagesNotes objects which contain a foreign key that references this object.
     *
     * If the $criteria is not null, it is used to always fetch the results from the database.
     * Otherwise the results are fetched from the database the first time, then cached.
     * Next time the same method is called without $criteria, the cached collection is returned.
     * If this DamagesCarDamages is new, it will return
     * an empty collection or the current collection; the criteria is ignored on a new object.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @return PropelObjectCollection|DamagesNotes[] List of DamagesNotes objects
     * @throws PropelException
     */
    public function getNotess($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collNotessPartial && !$this->isNew();
        if (null === $this->collNotess || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collNotess) {
                // return empty collection
                $this->initNotess();
            } else {
                $collNotess = DamagesNotesQuery::create(null, $criteria)
                    ->filterByCarDamages($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collNotessPartial && count($collNotess)) {
                      $this->initNotess(false);

                      foreach($collNotess as $obj) {
                        if (false == $this->collNotess->contains($obj)) {
                          $this->collNotess->append($obj);
                        }
                      }

                      $this->collNotessPartial = true;
                    }

                    return $collNotess;
                }

                if($partial && $this->collNotess) {
                    foreach($this->collNotess as $obj) {
                        if($obj->isNew()) {
                            $collNotess[] = $obj;
                        }
                    }
                }

                $this->collNotess = $collNotess;
                $this->collNotessPartial = false;
            }
        }

        return $this->collNotess;
    }

    /**
     * Sets a collection of Notes objects related by a one-to-many relationship
     * to the current object.
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
     * and new objects from the given Propel collection.
     *
     * @param PropelCollection $notess A Propel collection.
     * @param PropelPDO $con Optional connection object
     */
    public function setNotess(PropelCollection $notess, PropelPDO $con = null)
    {
        $this->notessScheduledForDeletion = $this->getNotess(new Criteria(), $con)->diff($notess);

        foreach ($this->notessScheduledForDeletion as $notesRemoved) {
            $notesRemoved->setCarDamages(null);
        }

        $this->collNotess = null;
        foreach ($notess as $notes) {
            $this->addNotes($notes);
        }

        $this->collNotess = $notess;
        $this->collNotessPartial = false;
    }

    /**
     * Returns the number of related DamagesNotes objects.
     *
     * @param Criteria $criteria
     * @param boolean $distinct
     * @param PropelPDO $con
     * @return int             Count of related DamagesNotes objects.
     * @throws PropelException
     */
    public function countNotess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    {
        $partial = $this->collNotessPartial && !$this->isNew();
        if (null === $this->collNotess || null !== $criteria || $partial) {
            if ($this->isNew() && null === $this->collNotess) {
                return 0;
            } else {
                if($partial && !$criteria) {
                    return count($this->getNotess());
                }
                $query = DamagesNotesQuery::create(null, $criteria);
                if ($distinct) {
                    $query->distinct();
                }

                return $query
                    ->filterByCarDamages($this)
                    ->count($con);
            }
        } else {
            return count($this->collNotess);
        }
    }

    /**
     * Method called to associate a DamagesNotes object to this object
     * through the DamagesNotes foreign key attribute.
     *
     * @param    DamagesNotes $l DamagesNotes
     * @return DamagesCarDamages The current object (for fluent API support)
     */
    public function addNotes(DamagesNotes $l)
    {
        if ($this->collNotess === null) {
            $this->initNotess();
            $this->collNotessPartial = true;
        }
        if (!$this->collNotess->contains($l)) { // only add it if the **same** object is not already associated
            $this->doAddNotes($l);
        }

        return $this;
    }

    /**
     * @param	Notes $notes The notes object to add.
     */
    protected function doAddNotes($notes)
    {
        $this->collNotess[]= $notes;
        $notes->setCarDamages($this);
    }

    /**
     * @param	Notes $notes The notes object to remove.
     */
    public function removeNotes($notes)
    {
        if ($this->getNotess()->contains($notes)) {
            $this->collNotess->remove($this->collNotess->search($notes));
            if (null === $this->notessScheduledForDeletion) {
                $this->notessScheduledForDeletion = clone $this->collNotess;
                $this->notessScheduledForDeletion->clear();
            }
            $this->notessScheduledForDeletion[]= $notes;
            $notes->setCarDamages(null);
        }
    }


    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this CarDamages is new, it will return
     * an empty collection; or if this CarDamages has previously
     * been saved, it will retrieve related Notess from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in CarDamages.
     *
     * @param Criteria $criteria optional Criteria object to narrow the query
     * @param PropelPDO $con optional connection object
     * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
     * @return PropelObjectCollection|DamagesNotes[] List of DamagesNotes objects
     */
    public function getNotessJoinDictNoteTypeDefinitions($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $query = DamagesNotesQuery::create(null, $criteria);
        $query->joinWith('DictNoteTypeDefinitions', $join_behavior);

        return $this->getNotess($query, $con);
    }

    /**
     * Clears the current object and sets all attributes to their default values
     */
    public function clear()
    {
        $this->id = null;
        $this->car_data_id = null;
        $this->status_id = null;
        $this->dict_perpetrator_id = null;
        $this->process_type_id = null;
        $this->related_car_damage = null;
        $this->ls_id = null;
        $this->ol_id = null;
        $this->discard_id = null;
        $this->discard_description = null;
        $this->damage_date = null;
        $this->dealer_report_date = null;
        $this->perpetrator_report_date = null;
        $this->damages_description = null;
        $this->description = null;
        $this->created = null;
        $this->modified = null;
        $this->alreadyInSave = false;
        $this->alreadyInValidation = false;
        $this->clearAllReferences();
        $this->resetModified();
        $this->setNew(true);
        $this->setDeleted(false);
    }

    /**
     * Resets all references to other model objects or collections of model objects.
     *
     * This method is a user-space workaround for PHP's inability to garbage collect
     * objects with circular references (even in PHP 5.3). This is currently necessary
     * when using Propel in certain daemon or large-volumne/high-memory operations.
     *
     * @param boolean $deep Whether to also clear the references on all referrer objects.
     */
    public function clearAllReferences($deep = false)
    {
        if ($deep) {
            if ($this->collAttachmentss) {
                foreach ($this->collAttachmentss as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collCarDamageChangeLogss) {
                foreach ($this->collCarDamageChangeLogss as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collCarDamagessRelatedById) {
                foreach ($this->collCarDamagessRelatedById as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collDamagess) {
                foreach ($this->collDamagess as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collEstimatedBudgetss) {
                foreach ($this->collEstimatedBudgetss as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collInvoicess) {
                foreach ($this->collInvoicess as $o) {
                    $o->clearAllReferences($deep);
                }
            }
            if ($this->collNotess) {
                foreach ($this->collNotess as $o) {
                    $o->clearAllReferences($deep);
                }
            }
        } // if ($deep)

        if ($this->collAttachmentss instanceof PropelCollection) {
            $this->collAttachmentss->clearIterator();
        }
        $this->collAttachmentss = null;
        if ($this->collCarDamageChangeLogss instanceof PropelCollection) {
            $this->collCarDamageChangeLogss->clearIterator();
        }
        $this->collCarDamageChangeLogss = null;
        if ($this->collCarDamagessRelatedById instanceof PropelCollection) {
            $this->collCarDamagessRelatedById->clearIterator();
        }
        $this->collCarDamagessRelatedById = null;
        if ($this->collDamagess instanceof PropelCollection) {
            $this->collDamagess->clearIterator();
        }
        $this->collDamagess = null;
        if ($this->collEstimatedBudgetss instanceof PropelCollection) {
            $this->collEstimatedBudgetss->clearIterator();
        }
        $this->collEstimatedBudgetss = null;
        if ($this->collInvoicess instanceof PropelCollection) {
            $this->collInvoicess->clearIterator();
        }
        $this->collInvoicess = null;
        if ($this->collNotess instanceof PropelCollection) {
            $this->collNotess->clearIterator();
        }
        $this->collNotess = null;
        $this->aCarDamagesRelatedByRelatedCarDamage = null;
        $this->aDictStatuses = null;
        $this->aCarData = null;
        $this->aUsersRelatedByLsId = null;
        $this->aUsersRelatedByOlId = null;
        $this->aDictDiscards = null;
        $this->aDictPerpetrators = null;
        $this->aProcessTypes = null;
    }

    /**
     * return the string representation of this object
     *
     * @return string
     */
    public function __toString()
    {
        return (string) $this->exportTo(DamagesCarDamagesPeer::DEFAULT_STRING_FORMAT);
    }

    /**
     * return true is the object is in saving state
     *
     * @return boolean
     */
    public function isAlreadyInSave()
    {
        return $this->alreadyInSave;
    }

}
